How do I use jQuery to ignore case when selecting?

前端 未结 4 828
不知归路
不知归路 2020-12-09 10:45

I\'m currently attempting to disable a link using the following jQuery selector:

$(\"a[href$=/sites/abcd/sectors]\").removeAttr(\"href\");

4条回答
  •  眼角桃花
    2020-12-09 11:02

    First this is NOT VALID expression since it contains \ ,

    If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^``{|}~ ) as

    a literal part of a name, you must escape the character with two backslashes: \\.

    Src : http://api.jquery.com/category/selectors/

    so you must escape the / to \\/

    so your expression will be $("a[href$=\\/sites\\/abcd\\/sectors]").removeAttr("href");

提交回复
热议问题