<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<script>
function ca(){
var a = document.getElementById("a");
a.id ="b";
}
</script>
<body>
<p id="a">我的id是a</p>
<button type="button" onclick="ca()">按钮</button>
</body>
</html>
补充:火狐下的“审查元素”能看到id从'a'变成'b',只能使用一次,因为点了按钮后,id就是b了,里面没有id='a'了。除非刷新