jquery color class
先附上代码<table width="100%" border="0" cellspacing="1" cellpadding="0" > <tr height="27" align="center" style="color:#fff;"> <td width="17%" height="35" bgcolor="#19283e" class="th01">a</td> <td width="33%" height="35" bgcolor="#19283e" class="th01">b</td> <td width="10%" height="35" bgcolor="#19283e" class="th01">c</td> <td width="33%" height="35" bgcolor="#19283e" class="th01">d</td> <td width="8%" height="35" bgcolor="#19283e" class="th01">e</td> </tr> <tr> <td colspan="7" height="25" align="left" > <table height="26" width="100%" cellspacing="0" cellpadding="0" style="margin-top:10px; background:url(/images/main/img09.gif);"> <tr> <td style="padding-left:8px;" width="21"><img align='absmiddle' src='/UpFile/League/Icon_51001627082010.jpg' style="max-width:90%" style="max-width:90%"/ alt="onmouseover 反应慢 一闪就过去 是为啥?_html/css_WEB-ITnose" ></td> <td style="padding-left:7px;" class="txt09">a--- D1</td> </tr> </table> </td> </tr> <tr> <!-- <td colspan="5" align="center" class="txt10" style="padding-left:4px;"> <table width="100%" id="box-table-a"> <tr>--> <td align="center" style="padding-left:4px;">09/29 11:00</td> <td align="center" id="id1_415520" class="list_td" onclick="addCart('ggu12',415520,1,'SMP','2013-09-29 11:00/sh:ke/SMP');" onMouseover="highlight(this, true);" onMouseOut="highlight(this, false);" > <span style="float:left;">sh</span> <span style="float:right;">205</span></td> <td align="center" id="id0_415520" onMouseover="highlight(this, true);" onMouseOut="highlight(this, false);" class="list_td" onclick="addCart('ggu12','415520',0,'SMP','2013-09-29 11:00/sh:ke/SMP');" > 320 </td> <td class="list_td" id="id2_415520" class="list_td" onclick="addCart('ggu12',415520,2,'SMP','2013-09-29 11:00/sh:ke/SMP');" onMouseOver="highlight(this, true);" onMouseOut="highlight(this, false);"><span style="float:left;">3030</span><span style="float:right;">ke</span></td> <td align="center" style="background-color:#2b2b2b; cursor:arow;"><font color="#FFCC00">ppl</font></td> <!-- </tr> </table> </td>--> </tr></table><sript>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 < tds.length; i++) { if (tds[i].className == "odd") { tds[i].style.color = color; } else { tds[i].style.color = color; } } }</script>
以上代码里 tr是循环出来的。 我附上的是其中一个table的数据
问题是td里的 onmouseover/out 效果 反应慢 鼠标上去了有的不会变效果 在一个 td里来回一下才出现效果 有时还是一闪就没了。 不知道是什么原因 。有没有人知道? 困惑了 2天 在不行 高手请求以上代码 改为 jquery的 也行 jquery 替代 onmouseover 效果。
回复讨论(解决方案)
<table width="100%" border="0" cellspacing="1" cellpadding="0" > <tr height="27" align="center" style="color:#fff;"> <td width="17%" height="35" bgcolor="#19283e" class="th01">a</td> <td width="33%" height="35" bgcolor="#19283e" class="th01">b</td> <td width="10%" height="35" bgcolor="#19283e" class="th01">c</td> <td width="33%" height="35" bgcolor="#19283e" class="th01">d</td> <td width="8%" height="35" bgcolor="#19283e" class="th01">e</td> </tr> <tr> <td colspan="7" height="25" align="left" > <table height="26" width="100%" cellspacing="0" cellpadding="0" style="margin-top:10px; background:url(/images/main/img09.gif);"> <tr> <td style="padding-left:8px;" width="21"><img align='absmiddle' src='/UpFile/League/Icon_51001627082010.jpg' style="max-width:90%" style="max-width:90%"/ alt="onmouseover 反应慢 一闪就过去 是为啥?_html/css_WEB-ITnose" ></td> <td style="padding-left:7px;" class="txt09">a--- D1</td> </tr> </table> </td> </tr> <tr> <!-- <td colspan="5" align="center" class="txt10" style="padding-left:4px;"> <table width="100%" id="box-table-a"> <tr>--> <td align="center" style="padding-left:4px;">09/29 11:00</td> <td align="center" id="id1_415520" class="list_td" onclick="addCart('ggu12',415520,1,'SMP','2013-09-29 11:00/sh:ke/SMP');" onMouseover="highlight(this, true);" onMouseOut="highlight(this, false);" > <span style="float:left;">sh</span> <span style="float:right;">205</span></td> <td align="center" id="id0_415520" onMouseover="highlight(this, true);" onMouseOut="highlight(this, false);" class="list_td" onclick="addCart('ggu12','415520',0,'SMP','2013-09-29 11:00/sh:ke/SMP');" > 320 </td> <td class="list_td" id="id2_415520" class="list_td" onclick="addCart('ggu12',415520,2,'SMP','2013-09-29 11:00/sh:ke/SMP');" onMouseOver="highlight(this, true);" onMouseOut="highlight(this, false);"><span style="float:left;">3030</span><span style="float:right;">ke</span></td> <td align="center" style="background-color:#2b2b2b; cursor:arow;"><font color="#FFCC00">ppl</font></td> <!-- </tr> </table> </td>--> </tr></table><script tepe="javascrit/text">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 < tds.length; i++) { if (tds[i].className == "odd") { tds[i].style.color = color; } else { tds[i].style.color = color; } } }</script>
试试吧
2楼 没什么改变啊 就是 <script> 这个?? 这个是 js文件里的 调用的。 <br /> <br /> 和这个没关系吧。。。。 </script>
发现 单独拿出来 html 保存的话 不卡 很正常。。 在 asp文件里循环输出的时候就 出毛病 。。
这个估计你的td太多了
请问这个效果 用 jquery 如何实现呢?
事件冒泡吧.. 改用jquery的 mosueEnter mouseLeave
LZ使用jquery实现的话,可以参照下面的:
var table = $("#table1"); // 假设table的id为table1function CreateTr() { var tr = $("<tr></tr>"); var td = GetTd(); $(td).appendTo(tr); $(tr).appendTo(table);}function GetTd() { var td = $("<td></td>"); $(td).bind("mouseenter", function() { // logic }); $(td).bind("mouseleave", function() { // logic }); return td;}

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Mac version
God-level code editing software (SublimeText3)