<!DOCTYPE>
<html>
<head>
<meta charset='utf-8'>
<title>隐藏</title>
<script type=text/javascript>
//封装
function getByClass(oParent,sClass)
{
var aEle=oParent.getElementsByTagName('*');
var aResult=[];
for(var i=0;i<aEle.length;i++)
{
if(aEle[i].className==sClass)
{
aResult.push(aEle[i]);
}
}
return aResult;
}
window.οnlοad=function()
{
var oUl=document.getElementById('ul1');
var aA=document.getElementsByTagName('a');
for(var i=0;i<aA.length;i++)
{
aA[i].οnclick=function()
{
this.parentNode.style.display='none';
}
}
var aList=getByClass(oUl,'list');
for(var i=0;i<aList.length;i++)
{
aList[i].style.background='blue';
}
}
</script>
</head>
<body>
<ul id="ul1">
<li>a<a href="javascript:;">隐藏</a></li>
<li class="list">b<a href="javascript:;">隐藏</a></li>
<li>c<a href="javascript:;">隐藏</a></li>
<li class="list">d<a href="javascript:;">隐藏</a></li>
<li>a<a href="javascript:;">隐藏</a></li>
<li class="list">b<a href="javascript:;">隐藏</a></li>
<li class="list">c<a href="javascript:;">隐藏</a></li>
<li>d<a href="javascript:;">隐藏</a></li>
</ul>
</body>
</html>