Friday, January 1, 2016

Contains using in jquery


// hide all elements which contains the text "abc"
$("p").each(function ()
{
    var that = $(this);

    if (that.text().indexOf("abc") > -1) that.hide();
});    
Here's a shorthand... which is about twice as fast:

$("p.value:contains('abc')").hide();

No comments:

Post a Comment