如果jquery要選擇的元素id中帶有點(diǎn)符號,在選擇時需要在點(diǎn)前面加上兩個反斜杠,如:
$("#address\.street").text("Enter this field");
具體代碼如下:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>>
<script type='text/javascript' src='jquery-1.9.1.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(window).load(function(){
//http://www.jb51.net
$("#address\.street").text("Enter this field");
});//]]>
</script>
</head>
<body>
<div id="address.street">
</div>
</body>
</html>
更多信息請查看IT技術(shù)專欄