jQuery selector for inputs with square brackets in the name attribute

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

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


         


        
5条回答
  •  没有蜡笔的小新
    2020-11-22 07:04

    You can use backslash to quote "funny" characters in your jQuery selectors:

    $('#input\\[23\\]')
    

    For attribute values, you can use quotes:

    $('input[name="weirdName[23]"]')
    

    Now, I'm a little confused by your example; what exactly does your HTML look like? Where does the string "inputName" show up, in particular?

    edit fixed bogosity; thanks @Dancrumb

提交回复
热议问题