escape dot in javascript

前端 未结 5 919
猫巷女王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:29

    You don't actually need to remote the .'s from the id. You simply need to escape any special characters in the selector. For example, to select the following element:

    ... you can use:

    $('#foo\\.bar');
    

提交回复
热议问题