jQuery selector for inputs with square brackets in the name attribute

I’m trying to select this element which has square brackets in the name attribute:

<input type="text" name="inputName[]" value="someValue">

I’ve tried this (which doesn’t work):

$('input[inputName[]=someValue]')

and neither does this:

$('input[inputName&#91;&#93;=someValue]')

or this:

$('input["inputName[]"=someValue]')

EDIT: As some of you have pointed out, $('input[inputName=someValue]') would never work. What I was trying to do was: $('input[name=inputName][value=someValue]'). (But with [] in the name attribute).

5 Answers
5

Leave a Comment