案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<p id="demo">请点击按钮来查明按钮是否指定了 onclick 属性。</p>
6
7
<button onclick="myFunction()">试一下</button>
8
9
<script>
10
11
function myFunction()
12
{
13
var btn=document.getElementsByTagName("BUTTON")[0];
14
var x=document.getElementById("demo");
15
x.innerHTML=btn.getAttributeNode("onclick").specified;
16
}
17
18
</script>
19
20
</body>
21
</html>
22