jQuery¼¼Êõ

ÌÔ±¦ÏÔʾȫ²¿·ÖÀࣨJqueryЧ¹û£©

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2016-01-19 09:03 ÎÒÒªÆÀÂÛ( )

!DOCTYPE html PUBLIC

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> *{ margin:0; padding:0;} body {font-size:12px;text-align:center;} a { color:#04D; text-decoration:none;} a:hover { color:#F50; text-decoration:underline;} .SubCategoryBox {width:600px; margin:0 auto; text-align:center;margin-top:40px;} .SubCategoryBox ul { list-style:none;} .SubCategoryBox ul li { display:block; float:left; width:200px; line-height:20px;} .showmore { clear:both; text-align:center;padding-top:10px;} .showmore a { display:block; width:120px; margin:0 auto; line-height:24px; border:1px solid #AAA;} .showmore a span { padding-left:15px; background:url(img/down.gif) no-repeat 0 0;} .promoted a { color:#F50;} </style> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ var $category=$("ul li:not(:last):gt(5)"); $category.hide(300);//ÏÈÈ¡³ö²»°üº¬ÆäËüÆ·ÅÆÏà»úµÄli£¬ÔÙÀ´ÅжÏË÷Òý´óÓÚ5µÄÈ«²¿Òþ²Ø //¸øÏÔʾȫ²¿Æ·ÅƼӵã»÷ʼþ $(".showmore>a").click(function(e){ if($category.is(":visible")){//Õâ¸ö¿´ÖØÒª£¬ÅжÏÒþ²ØµÄÔªËØÊÇ·ñµÄ¿É¼ûµÄ $category.hide(300);//ÏÔʾÒþ²ØÆ·ÅÆ $("span",this).text("ÏÔʾȫ²¿Æ·ÅÆ");//Ïà¶Ô¶¨Î» $("span",this).css("background","url(img/more.gif) no-repeat 0 0;");//Ïà¶Ô¶¨Î» }else{ $category.show(300);//ÏÔʾÒþ²ØÆ·ÅÆ $("span",this).text("¾«¼òÏÔʾƷÅÆ");//Ïà¶Ô¶¨Î» $("span",this).css("background","url(img/up.gif) no-repeat 0 0;");//Ïà¶Ô¶¨Î» e.preventDefault();//×èֹĬÈÏÁ´½ÓÐÐΪ } }); }); </script> <script type="text/javascript"> $(function(){ var $category=$("ul li:not(:last):gt(5)"); $category.hide(300);//ÏÈÈ¡³ö²»°üº¬ÆäËüÆ·ÅÆÏà»úµÄli£¬ÔÙÀ´ÅжÏË÷Òý´óÓÚ5µÄÈ«²¿Òþ²Ø //¸øÏÔʾȫ²¿Æ·ÅƼӵã»÷ʼþ $(".showmore>a").toggle(function(e){//ÓÃʼþÇл»À´×ö(µÚÒ»´Îµã»÷Ö´Ðеĺ¯Êý£¬µÚ¶þ´Îµã»÷Ö´Ðеĺ¯Êý) $category.hide(300);//ÏÔʾÒþ²ØÆ·ÅÆ $("span",this).text("ÏÔʾȫ²¿Æ·ÅÆ");//Ïà¶Ô¶¨Î» $("span",this).css("background","url(img/more.gif) no-repeat 0 0;");//Ïà¶Ô¶¨Î» e.preventDefault();//×èֹĬÈÏÁ´½ÓÐÐΪ },function(e){ $category.show(300);//ÏÔʾÒþ²ØÆ·ÅÆ $("span",this).css("background","url(img/up.gif) no-repeat 0 0;");//Ïà¶Ô¶¨Î» $("span",this).text("¾«¼òÏÔʾƷÅÆ");//Ïà¶Ô¶¨Î» e.preventDefault();//×èֹĬÈÏÁ´½ÓÐÐΪ }); }); </script> </head> <body> <div class="SubCategoryBox"> <ul> <li ><a href="#">¼ÑÄÜ</a><i>(30440) </i></li> <li ><a href="#">Ë÷Äá</a><i>(27220) </i></li> <li ><a href="#">ÈýÐÇ</a><i>(20808) </i></li> <li ><a href="#">Ä῵</a><i>(17821) </i></li> <li ><a href="#">ËÉÏÂ</a><i>(12289) </i></li> <li ><a href="#">¿¨Î÷Å·</a><i>(8242) </i></li> <li ><a href="#">¸»Ê¿</a><i>(14894) </i></li> <li ><a href="#">¿Â´ï</a><i>(9520) </i></li> <li ><a href="#">±öµÃ</a><i>(2195) </i></li> <li ><a href="#">Àí¹â</a><i>(4114) </i></li> <li ><a href="#">°ÂÁÖ°Í˹</a><i>(12205) </i></li> <li ><a href="#">Ã÷»ù</a><i>(1466) </i></li> <li ><a href="#">°®¹úÕß</a><i>(3091) </i></li> <li ><a href="#">ÆäËüÆ·ÅÆÏà»ú</a><i>(7275) </i></li> </ul> <div class="showmore"> <a href="more.html"><span>ÏÔʾȫ²¿Æ·ÅÆ</span></a> </div> </div> </body> </html> ¿´ÁË·æÀûµÄJqueryÒÔºó£¬ÓÃÉÏÃæµÄhtmlÉÏÃæ×öµÄ¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • jqueryÊó±êÐü¸¡ÏÔʾÌáʾÎÄ×Ö

    jqueryÊó±êÐü¸¡ÏÔʾÌáʾÎÄ×Ö

    2015-11-18 16:38

  • ÃÀÂú°ìÀíJSÖкº×Ö±íÏÖÂÒÂëÌâÄ¿£¨ÒÑ°ìÀí£©

    ÃÀÂú°ìÀíJSÖкº×Ö±íÏÖÂÒÂëÌâÄ¿£¨ÒÑ°ìÀí£©

    2015-11-16 10:22

  • Êó±ê±ÊÄ«±íÏÖÊâЧ

    Êó±ê±ÊÄ«±íÏÖÊâЧ

    2015-11-15 10:54

  • jquery·ÀÌÔ±¦ÍøͼƬ¶¯Ì¬¼ÓÔØ´úÂë

    jquery·ÀÌÔ±¦ÍøͼƬ¶¯Ì¬¼ÓÔØ´úÂë

    2015-11-13 18:39

ÍøÓѵãÆÀ
¨