escape dot in javascript

前端 未结 5 914
猫巷女王i
猫巷女王i 2020-12-10 15:49

jQuery selector can\'t select an ID if it contains a . in it.
in my application ID name generates dynamically from usernames.

How can I esca

5条回答
  •  鱼传尺愫
    2020-12-10 16:32

    The the jQuery documentation states that two backslashes are used to escape them.

    So your example would use $("#This\\.Is\\.ID\\.1")

提交回复
热议问题