文档加载完后再调用
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
.style01{
width:200px;
height:200px;
float:left;
background:#F63;}
</style>
</head><body>
<div class="style01"></div>
<div class="style01"></div>
<div class="style01"></div>
<div class="style01"></div>
<div class="style01"></div>
</body>
</html>
<script>
var rows=document.getElementsByClassName("style01")
for(i=0;i<rows.length;i++){
rows[i].onmouseover=function(){
this.style.border="#000 solid 1px"
} rows[i].onmouseout=function(){
this.style.border="0"
}
}</script>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
.style01{
width:200px;
height:200px;
float:left;
background:#F63;}
</style>
</head><body>
<div class="style01"></div>
<div class="style01"></div>
<div class="style01"></div>
<div class="style01"></div>
<div class="style01"></div>
</body>
</html>
<script>
var rows=document.getElementsByClassName("style01")
for(i=0;i<rows.length;i++){
rows[i].onmouseover=function(){
this.style.border="#000 solid 1px"
} rows[i].onmouseout=function(){
this.style.border="0"
}
}</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货