JQuery find a div with a certain classname and specific text

Viewed 6003

What I'm trying to do is is find an elements from all the child elements within my parent element (el) that have a certain class and a certain text. I just want the div

This works $(el).children().find("div") and finds all the children

So I want the div with inner text "hello" with a class of "selected"

$(el).children().find("div").text("hello").hasClass("selected");

The line above doesn't do anything or has some were side effect of changing all this child elements text to something random.

I am def NOT a jquery expert and can't seem to find the right combination of selectors to get the job done

2 Answers
Related