jquery to find all exact td matches

前端 未结 5 1491
陌清茗
陌清茗 2021-02-09 00:31
$(\'#servertable td:eq(\' + server + \')\')

this finds only 1 (first I think) match, how to find all matches. btw. td:contains will not work for me.

5条回答
  •  情话喂你
    2021-02-09 00:45

    Try :containsExact

    http://wowmotty.blogspot.com/2010/05/jquery-selectors-adding-contains-exact.html

        $.extend( $.expr[":"], {
     containsExact: $.expr.createPseudo ?
      $.expr.createPseudo(function(text) {
       return function(elem) {
        return $.trim(elem.innerHTML.toLowerCase()) === text.toLowerCase();
       };
      }) :
      // support: jQuery <1.8
      function(elem, i, match) {
       return $.trim(elem.innerHTML.toLowerCase()) === match[3].toLowerCase();
      },
    
     containsExactCase: $.expr.createPseudo ?
      $.expr.createPseudo(function(text) {
       return function(elem) {
        return $.trim(elem.innerHTML) === text;
       };
      }) :
      // support: jQuery <1.8
      function(elem, i, match) {
       return $.trim(elem.innerHTML) === match[3];
      },
    
     containsRegex: $.expr.createPseudo ?
      $.expr.createPseudo(function(text) {
       var reg = /^\/((?:\\\/|[^\/]) )\/([mig]{0,3})$/.exec(text);
       return function(elem) {
        return RegExp(reg[1], reg[2]).test($.trim(elem.innerHTML));
       };
      }) :
      // support: jQuery <1.8
      function(elem, i, match) {
       var reg = /^\/((?:\\\/|[^\/]) )\/([mig]{0,3})$/.exec(match[3]);
       return RegExp(reg[1], reg[2]).test($.trim(elem.innerHTML));
      }
    
    });
    

提交回复
热议问题