Jquery Select Element By Name Attribute
I have an input with the name attribute: how can I select this element? I tried $('input[name=data[foo][bar]]') but in vein.
Solution 1:
Add quotes to the attribute value, otherwise you get conflicting square brackets and a parse error:
$("input[name='data[foo][bar]']")
Solution 2:
$("input[name='data[foo][bar]']")
Solution 3:
$('input[name="data[foo][bar]"]')
http://api.jquery.com/attribute-equals-selector/ for more info
Solution 4:
Use
$("input[name=data\\[foo\\]\\[bar\\]]")
The documentation says:
If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, you must escape the character with two backslashes: \. For example, if you have an element with id="foo.bar", you can use the selector $("#foo\.bar").
Post a Comment for "Jquery Select Element By Name Attribute"