Przemek Przemek - 7 months ago 13
Javascript Question

Jquery .html() of all elements

I have something like this

$('.class').html();
, but it apply only to first element that match it. I'd like to match value of all elements in document with class
.class
.

Answer

You are selection all elements with class .class but to gather all html content you need to walk trough all of them:

var fullHtml;

$('.class').each(function() {
   fullHtml += $(this).html();
});

search items by containig text inside of it:

$('.class:contains("My Something to search")').each(function() {
   // do somethign with that
});

Code: http://jsfiddle.net/CC2rL/1/