如何从jQuery选择器中排除类? [英] How can I exclude a class from my jQuery selector?
本文介绍了如何从jQuery选择器中排除类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
$(":input[type='text']").wijtextbox();
我想要的是,如果我的文本框的类是本机的,则不应用wijtextbox().有没有一种方法可以通过添加到上面的选择器中以某种方式排除它?
What I would like is for the wijtextbox() NOT to be applied if the class of my textbox is native. Is there a way I can somehow exclude this by adding to the above selector?
为此设置一个wijtextbox:
Make this a wijtextbox:
<textarea class="wijmo-wijtextbox ui-widget ui-state-default ui-corner-all valid" >xx</textarea>
不要将其设置为wijtextbox:
Don't make this a wijtextbox:
<textarea class="native wijmo-wijtextbox ui-widget ui-state-default ui-corner-all valid" >xx</textarea>
推荐答案
此:
$("input[type='text']").not(".native").wijtextbox();
或者这个:
$("input[type='text']:not('.native')").wijtextbox();
应该可以解决问题.还有一个用于选择类型为text
的输入的快捷方式:
should do the trick. There's also a shortcut for selecting an input whose type is text
:
$("input:text").not(".native").wijtextbox();
not()
的更多信息此处.
编辑:由于似乎您需要选择文本区域,请尝试以下操作:
Since it appears you need to select a textarea, try the following:
$("textarea").not(".native").wijtextbox();
这篇关于如何从jQuery选择器中排除类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文