【问题标题】:jQuery: how to exclude IDs from .find()?jQuery:如何从 .find() 中排除 ID?
【发布时间】:2023-04-03 12:03:02
【问题描述】:

我有这个代码:

$("#someform").find("input:not[#myid]").change(function() {
....
});

但代码不起作用。

任务: 我需要选择所有输入,但排除带有ID="myid" 的输入。

非常感谢您的帮助!

【问题讨论】:

标签: jquery validation input find


【解决方案1】:

关闭,使用括号代替方括号

$("#someform").find("input:not(#myid)").change(function() {
....
});

:not()

【讨论】:

  • @An-70,很高兴它有帮助:)
【解决方案2】:

:not()的语法不正确,

$("#someform").find("input:not(#myid)").change(function() {
   //                       --^-- --^--
   ....
});

或者你可以使用not()

$("#someform").find("input").not("#myid").change(function() {
   ....
});

【讨论】:

    猜你喜欢
    • 2013-06-26
    • 2018-02-02
    • 2013-01-08
    • 2011-05-11
    • 1970-01-01
    • 2015-03-20
    • 2013-04-25
    • 1970-01-01
    • 2010-10-01
    相关资源
    最近更新 更多