JQ 设置属性 attr()

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title>新建H5模板</title>
</head>
<body>
<a id="link" target="_blank">onestopweb.cn</a>
<button>按钮</button>
<script src="jquery-1.10.1.min.js"></script>
<script>
$(function(){
	$("button").click(function(){
		$("#link").attr({
			"href":"http://www.onestopweb.cn/",
			"title":"一站式网络",
			"target":"_blank"
		});
	});
});
</script>
</body>
</html>

效果图:

 

猜你喜欢

转载自onestopweb.iteye.com/blog/2313450