<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
ul {
list-style-type: none;
cursor: pointer;
}
</style>
</head>
<body>
<ul>
<li score="60">张三的数学成绩</li>
<li score="90">赵四的数学成绩</li>
<li score="90">王五的数学成绩</li>
<li score="80">唐七的数学成绩</li>
<li score="50">宋八的数学成绩</li>
</ul>
<script src="common.js"></script>
<script>
var list = document.getElementsByTagName("li");
for (var i = 0; i < list.length; i++) {
list[i].onclick = function () {
// alert(this.score);//弹出undefined
alert(this.getAttribute("score"));
};
}
</script>
</body>
<input type="button" value="移除自定义属性" id="btn" />
<div id="dv" score="80分" class="cls"></div>
<script src="common.js"></script>
<script>
my$("btn").onclick = function () {
// my$("dv").removeAttribute("score");
// my$("dv").className = "";
//也可以移除元素的自带的属性
my$("dv").removeAttribute("class");
};
</script>