Javascript 在每个中排除一个元素

Javascript 在每个中排除一个元素,javascript,jquery,Javascript,Jquery,如何运行所有文本区域,不包括我有id的文本区域 $("textarea").each(function (i, v) { // i could use an "if" inside here, but would rather adjust the selector }); 我尝试过使用:not($(“#mySpecialTextarea”),但无法使用jquery 你也可以使用 .not()方法最终将为您提供更具可读性的 将复杂选择器或变量推入:not() 选择器过滤器。在大多数

如何运行所有文本区域,不包括我有id的文本区域

$("textarea").each(function (i, v) {
    // i could use an "if" inside here, but would rather adjust the selector
});
我尝试过使用
:not($(“#mySpecialTextarea”)
,但无法使用jquery

你也可以使用

.not()
方法最终将为您提供更具可读性的 将复杂选择器或变量推入
:not()
选择器过滤器。在大多数情况下,
.not()
是更好的选择

使用jquery

你也可以使用

.not()
方法最终将为您提供更具可读性的 将复杂选择器或变量推入
:not()
选择器过滤器。在大多数情况下,
.not()
是更好的选择

$("textarea").not('#mySpecialTextarea').each(function (i, v) {
    // your code
});
$("textarea:not('#mySpecialTextarea')").each(function (i, v) {
    // your code
});