Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to selector ID textbox array using jquery

I have the HTML code

<input id="info[text1]" type="text" value="1"/> <br>
<input id="info[text2]" type="text" value="2"/> <br>

I want to select id='info[text1]' using jquery but I can't, so can you help me?

like image 257
Đạt Hoài Avatar asked Oct 19 '12 11:10

Đạt Hoài


3 Answers

You have to escape the brackets with \\

$("#info\\[text1\\]")

see http://api.jquery.com/category/selectors/ (second paragraph)

like image 172
st3inn Avatar answered Nov 01 '22 02:11

st3inn


Try it this way.

$('input[id="info[text1]"]')
like image 28
henkieee Avatar answered Nov 01 '22 04:11

henkieee


Try this:

$('#info\\[text1\\]');

http://jsfiddle.net/UwrVn/

like image 43
undefined Avatar answered Nov 01 '22 03:11

undefined