In an HTML I created a “div” with an unique id. Within this “div” I have more “div”s, in which each contains a string. For example:
<div id="name">
<div>A</div>
<div>B</div>
</div>
What I want to do is to find the index of a “div” that contains a string, say “A”, within the “div” with id=”name”.
I think selector “:contains” should be used in combination with .index() but I can’t figure out the right syntax. This is what I’ve tried:
var index = $("#name"):contains(A).index("div");
try this
http://jsfiddle.net/GhPxD/1/