How to select html nodes by ID with jquery when the id contains a dot?

后端 未结 8 1053
生来不讨喜
生来不讨喜 2020-11-22 08:22

If my html looked like this:


    

        
8条回答
  •  北海茫月
    2020-11-22 08:38

    You don't need to escape anything if you use document.getElementById:

    $(document.getElementById('strange.id[]'))
    

    getElementById assumes the input is just an id attribute, so the dot won't be interpreted as a class selector.

提交回复
热议问题