I have a string containing html, including several divs. I need to get the html from one of those divs, which has the class ‘.image-desc’.
I thought I would be able to do the following, but it doesn’t work:
$('<div class="image-title">Title</div><div class="image-desc">Description</div>').find('.image-desc').html();
Any ideas on how I can do this?
The problem is that .find() will search for children, not elements in the current jQuery object.
Use .filter() to filter the current selection:
Working example on jsfiddle