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

jQuery :contains() Selector

0 votes
6 views
added Mar 26 in jQuery by LC Marshal First Warrant Officer (8,170 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 Example

0 votes
responded May 4 by LC Marshal First Warrant Officer (8,170 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 based Knowledge Exchange Platform, where you can share your finding or solution with other members of community.
...