jQuery selector for inputs with square brackets in the name attribute

后端 未结 5 1252
醉梦人生
醉梦人生 2020-11-22 06:18

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


         


        
5条回答
  •  独厮守ぢ
    2020-11-22 06:40

    The attribute selector syntax is [name=value] where name is the attribute name and value is the attribute value.

    So if you want to select all input elements with the attribute name having the value inputName[]:

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

    And if you want to check for two attributes (here: name and value):

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

提交回复
热议问题