怎么用javascript 给<ul><li><li/><li><li/><li><li/><li><li/></ul>添加每行的内容内容
2个回答
展开全部
<html>
<head>
<title>
UL LI
</title>
</head>
<body>
<ul>
<li>1</li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<script>
var _li = document.getElementsByTagName("li");
for(var i = 0;i<_li.length;i++){
_li[i].innerHTML = "我爱你";
_li[i].onmouseover = function(){
this.style.background = "red";
};
_li[i].onmouseout = function(){
this.style.background = "none";
};
}
</script>
</body>
</html>
<head>
<title>
UL LI
</title>
</head>
<body>
<ul>
<li>1</li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<script>
var _li = document.getElementsByTagName("li");
for(var i = 0;i<_li.length;i++){
_li[i].innerHTML = "我爱你";
_li[i].onmouseover = function(){
this.style.background = "red";
};
_li[i].onmouseout = function(){
this.style.background = "none";
};
}
</script>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询