sfhover 怎么工任的?_html/css_WEB-ITnose
function menuFix() { var sfEls = document.getElementById("nav").getElementsByTagName("li"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onMouseDown=function() { this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onMouseUp=function() { this.className+=(this.className.length>0? " ": "") + "sfhover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), ""); } }
回复讨论(解决方案)
一个css类名,
mouseover mouseout 来添加 删除这个类名
哪里能找到想细的介绍?
楼主 从这里开始吧
http://www.w3school.com.cn/
我就想问下,sfhover是不是自已设定的,还是标准里面的?
就是 css的类名,可以自己命名
.a{color:red;}
.test { color:blue; }
1,楼主错误字太多,标题“工任”,2楼“想细”
2,这一段CSS代码的作用是为某个元素增加删除一个css的class的,
比如原来的是
原来的是
删除同理,就是只把shover这个样式删除掉,其它样式保持不变
3,sfhover是自己起的名字,如果你懂是css a:hover的话,就明白它的意思了,
如果不懂,学习一下
多谢 6楼指教;
刚学css 所以很多不懂;
不过,css a:hover 这个是用到伪类技术,上面我提到的这句代码:
this.className+=(this.className.length>0? " ": "") + "sfhover"
得到的结果应该是 this.className 值:“sfefs[i].name sfhover” 或者"sfhover"
应该没用到伪类的这个技术,我的理解有没有错?

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit
