IE6-:悬停修复(铲)-简化

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IE6-:悬停修复(铲)-简化相关的知识,希望对你有一定的参考价值。

This is the javascript code that enables you to create hover effects also in IE6. It's clean, it's light, it's super! :)

Apply that code to your document (eg. in ) and in css add like this:

ul li:hover, ul li.shover { your css styles }

Explain: IE6 will on mouse over element add .shover to that element.
  1. <!--[if lte IE 6]>
  2. <script type="text/javascript">
  3. sfHover = function() {
  4. var sfEls = document.getElementById("mainNav").getElementsByTagName("LI");
  5. for (var i=0; i<sfEls.length; i++) {
  6. sfEls[i].onmouseover=function() {
  7. this.className+=" sfhover";
  8. }
  9. sfEls[i].onmouseout=function() {
  10. this.className=this.className.replace(new RegExp(" sfhover\b"), "");
  11. }
  12. }
  13. }
  14. if (window.attachEvent) window.attachEvent("onload", sfHover);
  15. </script>
  16. <![endif]-->

以上是关于IE6-:悬停修复(铲)-简化的主要内容,如果未能解决你的问题,请参考以下文章

收藏|分享前端开发常用代码片段

IE6 导航悬停

分享前端开发常用代码片段

IE6 悬停问题

关于js----------------分享前端开发常用代码片段

PNG IE6bug修复