jQuery v1.3.2通过属性查找元素 [英] jquery v1.3.2 find element by attribute
本文介绍了jQuery v1.3.2通过属性查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要查找并遍历具有特定属性的所有子元素.以下代码在jquery 1.2.6中工作正常,但在1.3.2中抛出异常
I need to find and iterate through all child elements that have specific attribute. The following code worked fine in jquery 1.2.6, but throws exception in 1.3.2
$(parentElement).find('*[@someAttributeName]').each(function(index){
doSomething(this);
});
实现该目标的正确方法是什么?
What is the correct way to achieve that?
推荐答案
相信我只要摆脱@.
$(parentElement).find('[someAttributeName]').each(function(index){
doSomething(this);
});
从jQuery 选择器文档:
From the jQuery selector docs:
注意:采用jQuery 1.3 [@attr]样式 选择器已删除(它们是 之前在jQuery 1.2中已弃用). 只需从您的帐户中删除"@"符号 选择器,以使它们工作 再次.
Note: In jQuery 1.3 [@attr] style selectors were removed (they were previously deprecated in jQuery 1.2). Simply remove the '@' symbol from your selectors in order to make them work again.
这篇关于jQuery v1.3.2通过属性查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文