Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery get object by name when name contains a "["-character

Consider this HTML:

<input type="text" name="inputa[42]" value="2012-05-02" />
<input type="text" name="inputb[42]" value="74,178" />

<input type="text" name="inputa[85]" value="2013-02-14" />
<input type="text" name="inputb[85]" value="21,35" />

How to use a jQuery selector to get the value of the input with name inputa[85]?

It would have been very easy if the name wouldn't have contained [85], but now I can't get $("input[name=inputa[85]]") to work which is understandable, but how to solve it (without changing the name attribute)?

like image 879
Simon Forsberg Avatar asked Dec 20 '22 20:12

Simon Forsberg


1 Answers

In quotes:

$("input[name='inputa[85]']")

or

$('input[name="inputa[85]"]')
like image 152
abuduba Avatar answered Dec 23 '22 09:12

abuduba