Home >Web Front-end >JS Tutorial >jQuery uses the attr() method to set multiple attribute values ​​​​at the same time_jquery

jQuery uses the attr() method to set multiple attribute values ​​​​at the same time_jquery

WBOY
WBOYOriginal
2016-05-16 16:07:261503browse

The example in this article describes the use of jQuery to use the attr() method to set multiple attribute values ​​​​at the same time. Share it with everyone for your reference. The details are as follows:

The following demonstration example allows you 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" : "http://www.jb51.net/list/list_172_1.htm",
   "title" : "jb51.net"
  });
 });
});
</script>
</head>
<body>
<p><a href="http://www.jb51.net/list/list_172_1.htm" id="w3s">jb51.net</a></p>
<button>点此改变链接与提示</button>
<p>鼠标滑过链接即可看到链接与提示信息已被更改.</p>
</body>
</html>

I hope this article will be helpful to everyone’s jQuery programming.

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