I want to find an element by class name. I know it will appear in a particular parent div, so rather than search the entire dom, I’d like to search only the particular div. I am trying this, but does not seem to be the correct syntax:
var element = $("#parentDiv").(".myClassNameOfInterest");
what’s the right way to do that?
Thanks
You were close. You can do:
.find()– http://api.jquery.com/findAlternatively, you can do:
…which sets the context of the jQuery object to the
#parentDiv.EDIT:
Additionally, it may be faster in some browsers if you do
div.myClassNameOfInterestinstead of just.myClassNameOfInterest.