JS+CSS Implementation classification dynamic selection and mobile function effect code _javascript skill

Source: Internet
Author: User

The example of this paper describes the dynamic selection of JS+CSS and the effect code of mobile function. Share to everyone for your reference, specific as follows:

This is a selection plug-in similar to the tab feature, and ordinary tab difference is added to the animation effect, more for the commodity site, used for commodity classification function, but other sites can also be used, click to run you will know its secret, it uses JavaScript simulation of the effect of Flash animation, very appropriate.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/js-css-cha-type-move-style-demo/

The specific code is as follows:

<HEAD> <title>js+css Commodity dynamic selection and mobile function </TITLE> <meta http-equiv= "Content-type content=" text/html; CHARSET=GBK "> <style language=" javascript "> <!--body, td{font-size:9pt; hidden{display:none
Splay:block;} --> </style> </HEAD> <BODY> <script language= "JavaScript" > <!--var speed=10;//speed var ci = 1 0;//movement number var left=0;//box left position var top=0;//box position var width=0;//box width var height=0;//box high Var aimleft=0;//target left position var aimtop=0;//target
Up position var aimwidth=0;//target wide var aimheight=0;//target high var lb=0;//left step var tb=0;//up step var wb=0;//wide step var hb=0;//high step var FK = null;
var aim = null;
var aim1 = null;
 function Initobj (OID) {if (!FK) {FK = document.getElementById (' FK ');}
 if (!aim) {aim = document.getElementById (' aim ');}
 if (!aim1) aim1 = document.getElementById (' aim1 ');
if (OID) append (Fk,document.getelementbyid (OID), true);
 The function append (o,oc,cloned) {while (O.haschildnodes ()) O.removechild (O.firstchild); if (cloned) OC = Oc.clonenode (TRUE);
 Oc.classname = ' show ';
O.appendchild (OC);
 } function SetSource (obj,oid) {initobj (OID); left = GetOffset (obj).
 Left; top = GetOffset (obj).
 Top;
 width = obj.offsetwidth;
 Height = obj.offsetheight; Aimleft = GetOffset (AIM).
 Left; Aimtop = GetOffset (AIM).
 Top;
 Aimwidth = Aim.offsetwidth;
 Aimheight = Aim.offsetheight;
 Fk.style.display= ';
Clearinterval (MyMar);
 /** * Set direction step, wide height step/function SetStep () {lb = (aimleft-left)/ci;
 TB = (aimtop-top)/ci;
 WB = (aimwidth-width)/ci;
HB = (aimheight-height)/ci;
 /** * Mobile/function Move () {setstep ();
 left+=lb;
 TOP+=TB;
 WIDTH+=WB;
 HEIGHT+=HB;
  if (left<aimleft-2 | | top<aimtop-2 | | width<aimwidth-2 | | height<aimheight-2) {fk.style.left = left+ "px";
  Fk.style.top = top+ "px";
  Fk.style.width = width+ "px";
 Fk.style.height = height+ "px";
  }else{if (FK) while (Fk.haschildnodes ()) {append (aim1,fk.firstchild);}
  HIDDENFK ();
 Clearinterval (MyMar)}} function Hiddenfk () {initobj ();
Fk.style.display= ' None '; }
/**
*Gets the position of an element in the page relative to the upper-left vertex of the page * * function getoffset (obj) {var offsetleft = Obj.offsetleft;
 var offsettop = obj.offsettop;
  while (obj.offsetparent!= document.body) {obj = obj.offsetparent;
  Offsetleft + = Obj.offsetleft;
 offsettop + = Obj.offsettop;
return {left:offsetleft, top:offsettop};
} var mymar=setinterval (move,speed); --> </SCRIPT> <div id= "FK" style= "Position:absolute; width:46px; height:20px; border:1px solid #000000; Display:none "></div> <table style=" border:1px solid #666666 cellspacing=1 bgcolor= #ff1111 cellpadding=4 border=0> <tr bgcolor= #ffffff > <td onclick= "SetSource" (This, ' T1 '); Mymar=setinterval (move,speed) ">ASP</TD> <td onclick=" SetSource (this, ' T2 '); {Mymar=setinterval (Move,speed)} ">PHP</TD> <td onclick=" SetSource (this, ' T3 '); {Mymar=setinterval (Move,speed)} ">ASP.NET</TD> <td onclick=" SetSource (this, ' T4 '); {Mymar=setinterval (Move,speed)} ">JSP</TD> <td onclick=" SetsourcE (this, ' T5 '); {Mymar=setinterval (Move,speed)} ">AJAX</TD> <td onclick=" SetSource (This, ' T6 '); {Mymar=setinterval (Move,speed)} ">DELPHI</TD> </TR> </TABLE> <br><br> <br> <br> <br><br> <table id= "aim" style= "border:1px solid #666666; width:227px; height:300px; " > <TR> <td id= ' aim1 ' valign= ' top ' ></TD> </TR> </TABLE> <br> <br> <br > <br> <table style= "border:1px solid #666666" cellspacing=1 bgcolor= #ff1111 cellpadding=4 border=0> < TR bgcolor= #ffffff > <td onclick= "SetSource" (This, ' T1 '); Mymar=setinterval (move,speed) ">ASP</TD> <td onclick=" SetSource (this, ' T2 '); {Mymar=setinterval (Move,speed)} ">PHP</TD> <td onclick=" SetSource (this, ' T3 '); {Mymar=setinterval (Move,speed)} ">ASP.NET</TD> <td onclick=" SetSource (this, ' T4 '); {Mymar=setinterval (Move,speed)} ">JSP</TD> <td onclick=" SetSource (This, ' T5 '); {Mymar=setintErval (Move,speed)} ">AJAX</TD> <td onclick=" SetSource (This, ' T6 '); {Mymar=setinterval (Move,speed)} ">DELPHI</TD> </TR> </TABLE> <div id=" T1 "class=" hidden "> asp</div> <div id= "T2" class= "hidden" >PHP</div> <div id= "T3" class= "hidden" >asp.net</div > <div id= "T4" class= "hidden" >JSP</div> <div id= "T5" class= "hidden" >AJAX</div> <div id= " T6 "class=" hidden ">DELPHI</div> </BODY>

I hope this article will help you with your JavaScript programming.

Related Article

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.