Hide all 'a' elements with text or innerHTML that matches the number '0' or a custom value using javascript or jQuery

后端 未结 2 2004
梦如初夏
梦如初夏 2021-02-06 17:00
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 17:36

    $('a:contains(foo)').hide();
    

    Done.

    Or:

    var customValue = "foo"
    $('a').filter(function(){
        return this.innerHTML === customValue;
    }).fadeOut();
    

    With the later option you custom it a lot more, like:

    var customValue = "foo"
    $('a').filter(function(){
        return this.innerHTML === customValue &&
               $(this).closest('div').length;
    }).fadeOut();
    

提交回复
热议问题