jQuery 按类和属性获取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7655909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery get by class and attribute
提问by AnonyMouse
Hi I have a select like:
嗨,我有一个选择:
<select id="item_OfficeUserId" class="dropdownauditor" name="item.OfficeUserId" invoicelineid="33">
In jQuery I can get it by its class:
在 jQuery 中,我可以通过它的类来获取它:
$(".dropdownauditor")
Is there a way to get it based on its class and it attribute invoicelineid="33" as well?
有没有办法根据它的类来获取它,并且它也属性invoicelineid =“33”?
There will be more than one with class="dropdownauditor"
. I want to get the selected item of the particular select
. I was using:
将不止一个与class="dropdownauditor"
. 我想获取特定select
. 我正在使用:
$(".dropdownauditor").change(function () {
$(".dropdownauditor option:selected").each(function () {
...
}
}
But this is running through the second part twice. ie. It tis then finding the selected for every select
with class="dropdownauditor"
Is is possible to only find only one with invoicelineid="33"
?
但这两次贯穿第二部分。IE。然后,它正寻求在选择每一个select
有class="dropdownauditor"
是可能仅发现只有一个invoicelineid="33"
?