首页 > 代码库 > jQuery attr() - 获取属性值

jQuery attr() - 获取属性值

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
alert($("#runoob").attr("href"));
});
});
</script>
</head>

<body>
<p><a href="http://www.cnblogs.com/yl514/p/7086393.html" id="runoob">测试</a></p>
<button>显示 href 属性的值</button>
</body>
</html>

jQuery attr() - 获取属性值