jQuery USES the attr of method to set multiple instances of property value usage at the same time

  • 2020-05-19 04:15:12
  • OfStack

This example demonstrates the use of jQuery to set multiple property values simultaneously using the attr() method. Share with you for your reference. The details are as follows:

The following example demonstrates the ability to modify links and prompts by clicking a button.


<!DOCTYPE html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
$(document).ready(function(){
 $("button").click(function(){
  $("#w3s").attr({
   "href" : "//www.ofstack.com/list/list_172_1.htm",
   "title" : "ofstack.com"
  });
 });
});
</script>
</head>
<body>
<p><a href="//www.ofstack.com/list/list_172_1.htm" id="w3s">ofstack.com</a></p>
<button> Click this change link with the prompt </button>
<p> Mouse over the link to see the link and the message has been changed .</p>
</body>
</html>

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


Related articles: