Selecting an ID with a colon in it with jQuery

前端 未结 4 1172
南笙
南笙 2020-11-29 09:46

I\'m working on a pre-written module for a site, and I need to target an element with the id test:two. Now, this element has a colon in it, so jQuery is presuma

4条回答
  •  执笔经年
    2020-11-29 10:45

    Simply escape the colon with a \\:

    $('#test\\:two');
    

    http://jsfiddle.net/zbX8K/3/


    See the docs: How do I select an element by an ID that has characters used in CSS notation?.

提交回复
热议问题