...">

JQuery gets an object by name when the name contains "[-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 jQuery selector to get input value named inputa[85] ?

It would be very easy if the name did not contain [85] , but now I can not get $("input[name=inputa[85]]") to work, which is understandable, but how to solve it (without changing the name attribute)?

+4
source share
2 answers

In quotation marks:

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

or

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

You can use $('input[name*="inputa"]') if you don't know the values ​​in brackets or the abuduba answer above.

+1
source

All Articles