<!DOCTYPE html>
<html xmlns= "http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv= "Content-Type"
content= "text/html; charset=utf-8"
/>
<title></title>
<script type= "text/javascript" >
window.onload = function
() {
//取出所有的a标签
var
oUl = document.getElementById( "ul1" );
var
aA = oUl.getElementsByTagName( "a" );
for
( var
i = 0; i < aA.length; i++) {
//给每个a标签注册事件
aA[i].onclick = function
() {
//this是当前元素,parentNode 是单数,因为每个节点,只有一个父节点!有多个子节点
this .parentNode.style.display = "none" ;
}
}
}
</script>
</head>
<body>
-----------点击“隐藏” 隐藏每行中的文字-----------
<ul id= "ul1" >
<li>电风扇发<a href= "javascript:void(0)" >隐藏</a></li>
<li>电松岛枫扇发<a href= "javascript:void(0)" >隐藏</a></li>
<li>大幅度<a href= "javascript:void(0)" >隐藏</a></li>
<li>合格后<a href= "javascript:void(0)" >隐藏</a></li>
<li>的发的发的我<a href= "javascript:void(0)" >隐藏</a></li>
</ul>
</body>
</html>
|