Reputation: 2430
I have the following input field:
<input type="hidden" name="field_tab_order[0]" />
How to access this using name attribute with jQuery. This must be easy. I am having trouble trying to access it like this:
jQuery('input[name=field_tab_order[0]]');
Upvotes: 0
Views: 80
Reputation: 318182
must quote
jQuery('input[name="field_tab_order[0]"]');
or escape
jQuery('input[name=field_tab_order\\[0\\]]');
when using certain characters in selector
Because jQuery uses CSS syntax for selecting elements, some characters are interpreted as CSS notation.
For example, periods, colons, braces etc. are problematic within the context of a jQuery selector because they indicate another atttribute selector nested in the first etc.
In order to tell jQuery to treat these characters literally rather than as CSS notation, they must be "escaped" by placing two backslashes in front of them.
Upvotes: 4
Reputation: 62488
you have to put quotes for name attribute value like this:
jQuery('input[name="field_tab_order[0]"]');
Upvotes: 2