a b c d e a--- D1 --> 09/29 11:00 sh 205 320 3030 ke ppl --> function highlight(obj, isHover) { var cssClass = obj.className; //alert(cssClass); if(cssClass == "" || cssClass == "MouseOver") { obj.className = isHover ? "MouseOver" : ""; return; } var color = "#000000"; var oddColor = "#000000"; if(isHover) { //obj.style.backgroundImage = "url(/images/main/bg19.gif)"; //alert(cssClass); obj.style.backgroundColor = "#FFCC00"; obj.style.borderColor = "#ffe066 #907608 #907608 #ffe066"; } else { color = ""; oddColor = ""; obj.style.backgroundColor = ""; obj.style.borderColor = ""; //obj.style.backgroundImage = "url(/images/main/bg09.gif)"; } obj.style.color = color; // set color of this element var tds = obj.getElementsByTagName("TD"); // and all child TDs for (var i = 0; i
以上代码里 tr是循环出来的。 我附上的是其中一个table的数据
问题是td里的 onmouseover/out 效果 反应慢 鼠标上去了有的不会变效果 在一个 td里来回一下才出现效果 有时还是一闪就没了。 不知道是什么原因 。有没有人知道? 困惑了 2天 在不行 高手请求以上代码 改为 jquery的 也行 jquery 替代 onmouseover 效果。
回复讨论(解决方案)
a b c d e a--- D1 --> 09/29 11:00 sh 205 320 3030 ke ppl --> function highlight(obj, isHover) { var cssClass = obj.className; //alert(cssClass); if(cssClass == "" || cssClass == "MouseOver") { obj.className = isHover ? "MouseOver" : ""; return; } var color = "#000000"; var oddColor = "#000000"; if(isHover) { //obj.style.backgroundImage = "url(/images/main/bg19.gif)"; //alert(cssClass); obj.style.backgroundColor = "#FFCC00"; obj.style.borderColor = "#ffe066 #907608 #907608 #ffe066"; } else { color = ""; oddColor = ""; obj.style.backgroundColor = ""; obj.style.borderColor = ""; //obj.style.backgroundImage = "url(/images/main/bg09.gif)"; } obj.style.color = color; // set color of this element var tds = obj.getElementsByTagName("td"); // and all child TDs for (var i = 0; i
试试吧
2楼 没什么改变啊 就是 这个?? 这个是 js文件里的 调用的。
和这个没关系吧。。。。
发现 单独拿出来 html 保存的话 不卡 很正常。。 在 asp文件里循环 输出的时候就 出毛病 。。
这个估计你的td太多了
请问这个效果 用 jquery 如何实现呢?
事件冒泡吧.. 改用jquery的 mosueEnter mouseLeave
LZ使用jquery实现的话,可以参照下面的:
var table = $("#table1"); // 假设table的id为table1function CreateTr() { var tr = $(" "); var td = GetTd(); $(td).appendTo(tr); $(tr).appendTo(table);}function GetTd() { var td = $(" "); $(td).bind("mouseenter", function() { // logic }); $(td).bind("mouseleave", function() { // logic }); return td;}
查看更多关于onmouseover反应慢一闪就过去是为啥?_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did112751