jquery v1.3.2按属性查找元素

我需要找到并遍历具有特定属性的所有子元素。 以下代码在jquery 1.2.6中运行良好,但在1.3.2中抛出exception

$(parentElement).find('*[@someAttributeName]').each(function(index){ doSomething(this); }); 

实现这一目标的正确方法是什么?

我相信只是摆脱@。

 $(parentElement).find('[someAttributeName]').each(function(index){ doSomething(this); }); 

从jQuery 选择器 docs:

注意:在jQuery 1.3 [@attr]样式选择器被删除(它们之前在jQuery 1.2中被弃用)。 只需从选择器中删除“@”符号即可使它们再次工作。

请注意,从版本1.2开始,不推荐使用属性名称之前的“@”。

 $(parentElement).find('*[someAttributeName]').each(function(index){ doSomething(this); }); 

只需删除它就可以了。

在jQuery 1.3中不推荐使用[@attribute]表示法。 删除@符号,你很高兴。

ithink这是找到并可以改变它的最佳方式

  $('.youritem').each(function(){ if($(this).attr('title') == 'add image') $(this).attr('id','imageuploader'); }); 

当我想找到带有required=""输入时,在IE中对我不起作用。

当我改为required="required" 。 也许其他组合也可以使用https://stackoverflow.com/a/3012975/588759