<html>
</head>
<script>
window.onload=w;
function w(){
var ap=document.getElementsByTagName("p");
for(var i=0; i<ap.length; i++){ap[i].onmouseover=function(){this.style.background="#008080"}}
}
</script>
<head>
<body>
<div style="background:#808000;width:500px">
<p>aaaaaaaaaa</p>
<p>bbbbbbbbbb</p>
<p>cccccccccc</p>
</div>
</body>
</html>
在IE下鼠标指向文字时改变背景颜色,但是指向文字所在的一行的空白处时却没反应,不知如何解决?还有鼠标离开后颜色转换回来有没有简单点的代码?
</head>
<script>
window.onload=w;
function w(){
var ap=document.getElementsByTagName("p");
for(var i=0; i<ap.length; i++){ap[i].onmouseover=function(){this.style.background="#008080"}}
}
</script>
<head>
<body>
<div style="background:#808000;width:500px">
<p>aaaaaaaaaa</p>
<p>bbbbbbbbbb</p>
<p>cccccccccc</p>
</div>
</body>
</html>
在IE下鼠标指向文字时改变背景颜色,但是指向文字所在的一行的空白处时却没反应,不知如何解决?还有鼠标离开后颜色转换回来有没有简单点的代码?
<html>
<head>
<script>
window.onload=w;
function w(){
var ap=document.getElementsByTagName("p");
for(var i=0; i<ap.length; i++){ap[i].onmouseover=function(){this.style.background="#008080"};ap[i].onmouseout=function(){this.style.background="#808000"}}
}
</script>
</head>
<body>
<div style="background:#808000;width:500px">
<p style="width:500px">aaaaaaaaaa</p>
<p>bbbbbbbbbb</p>
<p>cccccccccc</p>
</div>
</body>
</html>
<html>
<head>
<script>
window.onload=w;
function w(){
var ap=document.getElementsByTagName("li");
for(var i=0; i<ap.length; i++){
ap[i].onmouseover=function(){this.style.background="#008080"};
ap[i].onmouseout=function(){this.style.background="#808000"};
}
}
</script>
<style>
li {
list-style-type: none;
}
</style>
</head>
<body>
<ul style="background:#808000;width:500px">
<li style="width:500px">aaaaaaaaaa</li>
<li>bbbbbbbbbb</li>
<li>cccccccccc</li>
</ul>
</body>
</html>