【问题标题】:Syntax jQuery for contains test包含测试的 jQuery 语法
【发布时间】:2014-08-07 17:01:52
【问题描述】:

我想测试我的表是否有包含两个包含的行。我已经对此进行了测试,但它不起作用:

$("#resultat tr:not(:contains("+$('.devoirs option:selected ').text()+"))","#resultat tr:not(:contains("+$('.formateur option:selected ').text()+"))").each(function () {
    $(this).hide();
});

【问题讨论】:

    标签: jquery html-table row contains


    【解决方案1】:

    首先,:not() 不支持 true 伪选择器,:contains 是 jQuery 特定的。

    您可能想使用明确的.not()

    $('#resultat tr').not(':contains("'+$('.devoirs option:selected ').text()+'")')
    .end().not(':contains("'+$('.formateur option:selected ').text()+'")').each(function(){
        // do something 
    });
    

    【讨论】:

    • 感谢 .not() 但当我有两个包含其中一个完美运行时,代码不起作用。谢谢
    猜你喜欢
    • 2010-09-26
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 2019-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多