jQuery :contains() Selector

0 votes
230 views
added Mar 26, 2018 in jQuery by LC Marshal Captain (25,790 points)
edited May 4, 2018 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, 2018 by LC Marshal Captain (25,790 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.
...