案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<p id="demo">请点击按钮来查明 P 元素中的首个属性是 ID 属性。</p>
6
7
<button onclick="myFunction()">试一下</button>
8
9
<script>
10
function myFunction()
11
{
12
var x=document.getElementById("demo");
13
x.innerHTML=x.attributes[0].isId;
14
}
15
</script>
16
17
<p><b>注释:</b>Internet Explorer 或 Opera 不支持 isId 属性。</p>
18
19
</body>
20
</html>
21