jQuery按名称属性选择元素 [英] jquery select element by name attribute
本文介绍了jQuery按名称属性选择元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个输入,其名称属性为:
I have an input with the name attribute:
<input type="text" name="data[foo][bar]" />
如何选择此元素?
我尝试过$("input[name=data[foo][bar]]")
,但是是静脉注射.
I tried $("input[name=data[foo][bar]]")
but in vein.
推荐答案
在属性值中添加引号,否则会出现冲突的方括号和解析错误:
Add quotes to the attribute value, otherwise you get conflicting square brackets and a parse error:
$("input[name='data[foo][bar]']")
这篇关于jQuery按名称属性选择元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文