jQuery selects the method of the id attribute with the dotted element

  • 2020-05-16 06:24:20
  • OfStack

This example demonstrates how jQuery selects an id attribute with a dotted element. Share with you for your reference. The specific analysis is as follows:

If the element jquery wants to select has a dot symbol in id, you need to add two backslashes before the dot when selecting, such as:


$("#address\\.street").text("Enter this field");

The specific code is as follows:


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> //www.ofstack.com</title>
<script type='text/javascript' src='jquery-1.9.1.js'></script>
<script type='text/javascript'>
//<![CDATA[ 
$(window).load(function(){
////www.ofstack.com
$("#address\\.street").text("Enter this field");
});//]]> 
</script>
</head>
<body>
 <div id="address.street">
  //www.ofstack.com
</div>
</body>
</html>

I hope this article is helpful for you to design jQuery program.


Related articles: