<html>
<head>
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
function getByJs(that) {
alert(that.getAttribute("button1"));
}
function getByJquery(that) {
alert($(that).attr("button2"));
}
$(function () {
$('body').delegate("[getAttr]", "click", function () {
var that = $(this);
var button3 = that.attr("button3");
alert(button3);
})
})
</script>
<title>js和jQuery获取点击按钮的属性</title>
</head>
<body>
<div button1="点击js获取" onclick="getByJs(this)">点击js获取</div>
<div button2="点击jQuery获取" onclick="getByJquery(this)">点击jQuery获取</div>
<div getAttr="XXXX" button3='delegate()获取'>delegate()</div>
</body>
</html>