在HTML里怎样让鼠标移上去变颜色
发布网友
发布时间:2022-05-06 01:27
我来回答
共1个回答
热心网友
时间:2022-04-19 06:09
表格行指向变色,请运行偶写的代码: <script type="text/javascript">
function table_tr_changec(){
var tableObj=document.getElementById('de_table') ;
var tableobj_tr=tableObj.getElementsByTagName('tr');
var tableobj_tr_len=tableobj_tr.length;
var hover_color='#FF0000';
var normal_color='#FFFFFF';
for(var i=0;i<tableobj_tr_len;i++){
this.flog=0;
tableobj_tr[i].onmouseover=function (){
this.style.cursor='pointer';
this.flog=1;
if(this.flog==1){
this.style.backgroundColor=hover_color;
}
}
tableobj_tr[i].onmouseout=function (){
this.flog=0;
this.style.backgroundColor=normal_color;
}
}
} var ta_lock;
function table_hover(){
ta_lock=setInterval("table_tr_changec()");
}
function table_out(){
clearInterval(ta_lock);
}
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="de_table" onmouseover="table_hover()" onmouseout="table_out()">
<tr>
<td>dfdf</td>
<td>dsf</td>
</tr>
<tr>
<td>fdsf</td>
<td>sdf</td>
</tr>
<tr>
<td>sdfs</td>
<td>sdfsd</td>
</tr>
</table>