In the method below I can search divs with a class of bar for the text foo and underline the text contained within:
function UnderlineText() {
$(".bar").filter(":contains(foo)").css("text-decoration", "underline");
}
But I would like to pass a parameter to the method instead containing the string foo.
I have tried various permutations as seen in a previous question about the deprecated .contains
but I can't get it to work.
What is the best way to achieve this?
function UnderlineText(searchText) {
$(".bar").filter(":contains(*searchText*)").css("text-decoration", "underline");
}