Is there a case insensitive jQuery :contains selector?

后端 未结 12 2122
悲哀的现实
悲哀的现实 2020-11-22 02:45

Is there a case insensitive version of the :contains jQuery selector or should I do the work manually by looping over all elements and comparing their .text() to my string?<

12条回答
  •  隐瞒了意图╮
    2020-11-22 02:50

    I had a similar problem with the following not working...

    // This doesn't catch flac or Flac
    $('div.story span.Quality:not(:contains("FLAC"))').css("background-color", 'yellow');
    

    This works and without the need for an extension

    $('div.story span.Quality:not([data*="flac"])').css("background-color", 'yellow');
    

    This works too, but probably falls into the "manually looping" category....

    $('div.story span.Quality').contents().filter(function()
    {
      return !/flac/i.test(this.nodeValue);
    }).parent().css("background-color", 'yellow');
    

提交回复
热议问题