ITeye博客

jquery中 特殊字符的查询

wangleide414 · 2013-12-18 19:07 · 开发经验 · 编程语言 · Markdown

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript"> 
 
$(document).ready(function(){
    $(":input[name=test\\[user\\]]").css("background-color","#B2E0FF");
});
 
</script>	
 
</head>
<body>
<html>
<body>
 
<form action="">
Name: <input type="text" name="test[user]" />
<br />
Password: <input type="password" name="password" />
<br />
<button type="button">Useless Button</button>
<input type="button" value="Another useless button" />
<br />
<input type="reset" value="Reset" />
<input type="submit" value="Submit" />
<br />
</form>
 
</body>
</html>

 

上例中

$(":input[name=test\\[user\\]]").css("background-color","#B2E0FF"); 

中使用 \\[ 和 \\] 来分表表示 [ 和 ] 可以直接定位到name叫 test[user] 的

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。