Home >Web Front-end >JS Tutorial >Implementation of jQuery special symbol escaping

Implementation of jQuery special symbol escaping

高洛峰
高洛峰Original
2016-12-03 14:30:571421browse

我们在使用jquery选择器的时候 对一些ID属性中有特殊符号的地方需要进行转义。

列举部分如下:

<input id="entity.username" type="text" value="hello" />
alert($("#entity\\.username").val());
 
<input id="entity:username" type="text" value="hello" />
alert($("#entity\\:username").val());
 
//中间是空格
<input id="entity username" type="text" value="hello" />
alert($("#entity\\ username").val());
 
<input id="entity[username]" type="text" value="hello" />
alert($("#entity\\[username\\]").val());

   

以上这篇jQuery特殊符号转义的实现就是小编分享给大家的全部内容了


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn