亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JS 實(shí)現(xiàn)點(diǎn)擊a標(biāo)簽的時(shí)候讓其背景更換

 更新時(shí)間:2013年10月15日 16:38:56   作者:  
點(diǎn)擊a標(biāo)簽的時(shí)候給其換背景的方法有很多,在本文將為大家介紹下js是如何實(shí)現(xiàn)的,感興趣的朋友不要錯(cuò)過(guò)
復(fù)制代碼 代碼如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type=text/javascript src="alabel.js"></script>
<style type="text/css">
.curr{background:blue;display:inline;}
</style>

</head>
<body>
<div class="clMenu">
<span><a href="#">1</a></span>
</div>

</body>
</html>

在alabel.js中:
復(fù)制代碼 代碼如下:

window.onload = function ()
{
var aspan = document.getElementsByTagName("span");
var i = 0;
for (i = 0; i < aspan.length; i++)
{
aspan[i].onclick = function ()
{
for (i = 0; i < aspan.length; i++) aspan[i].className = "";
this.className = "curr";
};
}
};

這樣就可以實(shí)現(xiàn)在點(diǎn)擊a標(biāo)簽的時(shí)候給其添加紅色的背景。

注意:curr的屬性中display不能是block,否則添加的背景是一整行。

相關(guān)文章

最新評(píng)論