Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery :contains() Selector

0 votes
11 views
added Mar 26 in jQuery by LC Marshal Lieutenant (14,830 points)
edited May 4 by LC Marshal

find word of 'John' in div.content  using :contains() selector and add CSS style property 

$('.content:contains('John')' ).css( "text-decoration", "underline" );

1 Response

0 votes
responded May 4 by LC Marshal Lieutenant (14,830 points)

remove the word page from id

$('#forum-cat:contains(page)').filter(function() {
    return $(this).children().length === 0;  // exclude divs with children
}).text(function(index, text) {
    return text.replace(/page/g, '');
});
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...