【问题标题】:How to use JQuery contains for exact string [duplicate]如何使用 JQuery 包含精确字符串 [重复]
【发布时间】:2014-02-03 13:31:24
【问题描述】:

jQuery 包含如何用于选择精确字符串?

这是一个工作代码,用于在包含字符串树的每个表行中设置行颜色。

$( "#AnsprechpartnerTabelle tr:contains('" + x + "')").css( "background-color", "red" );    

问题是包含“treeapple”作为内容的行也被选中了。

那么它如何构建它像用户故事一样工作?

【问题讨论】:

    标签: javascript jquery


    【解决方案1】:

    用途:

    $("#AnsprechpartnerTabelle tr").filter(function() {
    return $(this).text() === x;
    }).css( "background-color", "red" );  
    

    【讨论】:

      猜你喜欢
      • 2011-04-13
      • 1970-01-01
      • 1970-01-01
      • 2017-12-13
      • 2013-09-12
      • 1970-01-01
      • 2016-04-14
      • 2012-11-14
      相关资源
      最近更新 更多