js动态设置鼠标悬浮
? js代碼自定義鼠標懸浮事件方法
//鼠標懸浮事件
function mover(obj){
var tdId=$(obj).attr("id");
var typeId=$(obj).children().next().val();
if(typeId!="" && typeId!=null){
if(tdId=="td1"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event11_11.png)");
}else if(tdId=="td2"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event12_12.png)");
}else if(tdId=="td3"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event13_13.png)");
}else if(tdId=="td4"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event14_14.png)");
}
}
}
//鼠標移動事件
function mout(obj){
var tdId=$(obj).attr("id");
var typeId=$(obj).children().next().val();
if(typeId!="" && typeId!=null){
if(tdId=="td1"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event01_1.png)");
}else if(tdId=="td2"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event02_2.png)");
}else if(tdId=="td3"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event03_3.png)");
}else if(tdId=="td4"){
$(obj).css("background-image","url(${cxt!}/cockpit/event/images/event04_4.png)");
}
}
}
html頁面td調用代碼
? <td width="96" style="background-image:url(images/event022.png);background-repeat:no-repeat;height:96px" id="td2" οnclick="tdOnclick(this)" οnmοuseοver="mover(this)" οnmοuseοut="mout(this)">
<div style="text-align: center;margin-top: 35px;color: #F60000;font-family: 微軟雅黑;font-size: 15px;" id="div2"></div>
<input id="input_2" type="hidden"/>
? ? ? ? </td>
總結
以上是生活随笔為你收集整理的js动态设置鼠标悬浮的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: monkeyrunner 使用
- 下一篇: Python 中5种下划线的含义都是什么