js动态设置鼠标悬浮

来源:互联网 发布:sql developer使用 编辑:程序博客网 时间:2024/04/28 23:51

  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" onclick="tdOnclick(this)" onmouseover="mover(this)" onmouseout="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>

原创粉丝点击