A simple JS mouse across the switch effect _javascript skills

Source: Internet
Author: User
Last time to help a friend wrote a simple switch effect, super simple, but also more applicable. Because of the CSS sprite technology, the demo comes with IE6-compatible PNG JS.

Core JavaScript code: Click here to view demo
Copy Code code as follows:

@Mr. To get the object property compatibility method
function $ (objectId) {
if (document.getElementById && document.getElementById (objectId)) {
return document.getElementById (OBJECTID);//The Consortium DOM
else if (document.all && document.all (objectId)) {
return document.all (OBJECTID);//MSIE 4 DOM
else if (document.layers && Document.layers[objectid]) {
Return document.layers[objectid];//NN 4 DOM. This is won ' t find nested layers
} else {
return false;
}
}
@Mr. See toggle display text and background map position
function Ileftnav (type) {
var inum,i_navinfo=$ ("I_navinfo");
if (type== "Writeblog") {
Inum= " -300px";
}else if (type== "Sharepic") {
Inum= " -600px";
}else if (type== "Writemsg") {
Inum= " -900px";
}else{
Inum= " -300px";
}
i_navinfo.innerhtml=$ (type). InnerHTML;
i_navinfo.style.backgroundposition=inum+ "0";
}
@Mr. Do you load mouse over events
Window.onload=function () {
var liitem=$ ("I_blognav"). getElementsByTagName ("Li");
for (var i=0; i<liitem.length; i++) {
Liitem[0].onmouseover=function () {Ileftnav ("Writeblog")}
Liitem[1].onmouseover=function () {Ileftnav ("Sharepic")}
Liitem[2].onmouseover=function () {Ileftnav ("writemsg")}
}
}

This article is a simple mouse mo over effect, with CSS can also be achieved, but relatively cumbersome. If you need a cooler, more flashy effect, click here to view the jquery-based bubble tip that Cssrain writes.
The original published in Mr.think's personal blog: http://mrthink.net/script-mousechange-simple/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.