jQuery¼¼Êõ

Ìá¸ßJQueryÐÔÄܵļ¸¸ö¼¼ÇÉ

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2015-09-22 13:06 ÎÒÒªÆÀÂÛ( )

ÔÚÑ¡Ôñʱ£¬×îºÃÒÔIDÑ¡Ôñ·û×÷Ϊ¿ªÍ·ÎÒÏëÕâ¸öºÜºÃÀí½â£¬ÒòΪJQueryÄÚ²¿Ê¹ÓÃdocument.getElementByID·½·¨½øÐÐIDÑ¡Ôñ£¬ÕâÖÖ·½·¨±ÈÆäËûËùÓжÔDOMÑ¡ÔñµÄ·½·¨¸ü¿ì£¬ËùÒÔ

jQuery ½Ì³Ì jQuery Ê×Ò³
jQuery ¼ò½é
jQuery Óï·¨
jQuery Ñ¡ÔñÆ÷
jQuery ʼþ

jQuery Ч¹û jQuery Òþ²Ø/ÏÔʾ
jQuery µ­Èëµ­³ö
jQuery »¬¶¯
jQuery ¶¯»­
jQuery stop()
jQuery Callback
jQuery Chaining

jQuery HTML jQuery »ñÈ¡
jQuery ÉèÖÃ
jQuery Ìí¼Ó
jQuery ɾ³ý
jQuery CSS Àà
jQuery css()
jQuery ³ß´ç

jQuery ±éÀú jQuery ±éÀú
jQuery ×æÏÈ
jQuery ºó´ú
jQuery ͬ°û
jQuery ¹ýÂË

jQuery AJAX jQuery AJAX ¼ò½é
jQuery ¼ÓÔØ
jQuery Get/Post

jQuery ÔÓÏî jQuery noConflict()

jQuery ʵÀý jQuery ʵÀý

jQuery ²Î¿¼ÊÖ²á jQuery ²Î¿¼ÊÖ²á
jQuery Ñ¡ÔñÆ÷
jQuery ʼþ
jQuery Ч¹û
jQuery Îĵµ²Ù×÷
jQuery ÊôÐÔ
jQuery CSS
jQuery Ajax
jQuery ±éÀú
jQuery Êý¾Ý
jQuery DOM ÔªËØ
jQuery ºËÐÄ

jQuery Mobile jQuery Mobile ʵÀý

Ìá¸ßJQueryÐÔÄܵļ¸¸ö¼¼ÇÉ jQuery #ÐÔÄÜ #¼¼ÇÉ2012-08-28 08:54 ÔÚÑ¡Ôñʱ£¬×îºÃÒÔIDÑ¡Ôñ·û×÷Ϊ¿ªÍ·

ÎÒÏëÕâ¸öºÜºÃÀí½â£¬ÒòΪJQueryÄÚ²¿Ê¹ÓÃdocument.getElementByID·½·¨½øÐÐIDÑ¡Ôñ£¬ÕâÖÖ·½·¨±ÈÆäËûËùÓжÔDOMÑ¡ÔñµÄ·½·¨¸ü¿ì£¬ËùÒÔÒÔ$("#")¿ªÍ·ÊÇ×îºÃµÄ,±ÈÈç:

<div id="a"> <div class="b"> <div class="c"> <div class="d"></div> </div> </div> </div> <script type="text/javascript"> $(".b .c .d")//slow one $("#a .b .c .d")//fast one </script> 
Ìṩ$()µÄÉÏÏÂÎÄ

ÔÚʹÓÃ$()Ñ¡ÔñÒ³ÃæÔªËØʱ£¬ÌṩѡÔñµÄ·¶Î§¿ÉÒÔ¼õÉÙÑ¡ÔñµÄʱ¼ä£¬»»¾ä»°Ëµ£¬ÈÃÑ¡ÔñÆ÷Ö»ÔÚÒ³ÃæµÄһСƬ·¶Î§ÄÚɸѡ¶ø²»ÊÇÕû¸öÒ³Ã浱Ȼ»á¼õÉÙɸѡʱ¼ä£¬Í¨¹ýÔÚ$()º¯ÊýÄÚÌṩµÚ¶þ¸ö²ÎÊý×÷ΪÉÏÏÂÎÄ¿ÉÒÔʵÏÖÕâÒ»µã

<div id="test"> <div class="inner">hi</div> </div> <script type="text/javascript"> alert($(".inner", document.getElementById("test")).text());//increase the speed by provide context alert($(".inner").text());//traverse all the element so that is slower than above </script>
µ±È»£¬ÔÚjquery¶¨Òå(»òÕßjsº¯Êý)ʼþÄÚ,¿ÉÒÔͨ¹ýthisÀ´Ö¸´úÉÏÏÂÎÄ:

<div id="test"> <div class="inner">hi</div> </div> <script type="text/javascript"> $("#test").click(function() { var text = $(".inner", this).text(); //this means $("#test") alert(text);//alert hi }); </script>

µ±È»£¬ÉÏÃæµÄÀý×ÓÒ²¿ÉÒÔд³ÉÏÂÃæÁ½ÖÖ·½Ê½£º

<div id="test"> <div class="inner">hi</div> </div> <script type="text/javascript"> alert($("#test .inner").text()); //method 1 alert($("#test").find(".inner").text());//method 2 and it was best one </script>

ÆäÖÐÀûÓÃfind·½·¨ÊÇËùÓз½·¨ÖÐЧÂÊ×î¸ßµÄ
 
µ±È»£¬Èç¹ûÄãÊÇͨ¹ýidÑ¡Ôñ·û£¬Ò²¾ÍÊÇ$("#..")À´Ñ¡Ôñ£¬²»ÐèÒªÌṩÉÏÏÂÎIJÎÊý.Õâ¶ÔËÙ¶ÈûÓÐÓ°Ïì
 
½«¾­³£ÓõÄJQuery°ü×°ºÃµÄÔªËؽøÐб£´æ

ÈçÌ⣬Õâµã±È½ÏÖØÒª£¬ÒòΪʹÓÃ$()¶ÔÒ³ÃæÔªËؽøÐÐÑ¡ÔñÊÇÐèÒªºÄ·Ñʱ¼äµÄ.¶ø±£´æΪ±äÁ¿½øÐÐʹÓÃʱ£¬¿ÉÒÔ±ÜÃâÕâÖÖÀË·Ñ£¬±ÈÈ磺

<ul> <li>one</li> <li>two</li> <li>three</li> <li>four</li> <li>five</li> </ul> <script type="text/javascript"> for (i = 0; i < $("ul li").length; i++) {//very bad,select $("ul li") so many times,waste a lot of time alert($("ul li")[i].innerHTML);//same here,very bad } var $li = $("ul li"); for (i = 0; i < $li.length; i++) {//good one,only selct $("ul li") once alert($li[i].innerHTML); //same here,good } </script>
´Ó´úÂë¿ÉÒÔ¿´µ½£¬±ÜÃâ¶à´ÎÖظ´Ñ¡Ôñ¿ÉÒÔÌá¸ßÐÔÄÜ:-)
 
¾¡Á¿ÉÙÓÃÑ¡Ôñ·û

JQueryµÄÑ¡ÔñÆ÷ÊÇÃæÏòÊý×éµÄ£¬ËùÒÔÔÚÌõ¼þÔÊÐíµÄÇé¿öϾ¡Á¿ÉÙÓÃÑ¡ÔñÆ÷£¬±ÈÈ磺

<div id="Div0"></div> <div id="Div1"></div> <div id="Div2"></div> <script type="text/javascript"> $("#Div0").slideDown("slow"); $("#Div1").slideDown("slow"); $("#Div2").slideDown("slow");//slow $("Div0,Div1,Div2").slideDown("slow");//fast </script>
¿ÉÒÔ¿´³ö£¬Ê¹ÓÃÑ¡ÔñÆ÷²¢ÓöººÅ½«±»Ñ¡ÔñµÄÔªËØ·Ö¿ª£¬²¢Ñ¡Ôñ¶à¸öÔªËز»½öÈôúÂë¸ü¼Ó¼ò½à£¬²¢ÇÒͨ¹ý¼õÉÙ´´½¨JQueryµÄʵÀýËùÒÔÔÚÐÔÄÜÉÏÒ²ÉÔʤһ³ï!
 
ÔÚÑ­»·´ÎÊýºÜ¶àʱ±ÜÃâʹÓÃ$().each,¶øʹÓÃforÑ­»·

ʹÓÃ$().each·½·¨ÈÃÔÚ½øÐÐÑ­»·Ê±£¬»áÈñà³Ì¸ü¼ÓÇáËÉ£¬ÉÙÁ¿µÄÑ­»·ÔÚʹÓÃ$().eachʱ¶ÔÐÔÄܵÄÓ°Ïì¿ÉÒÔºöÂÔ²»¼Æ£¬µ«Êǵ±Õâ¸öÊý×ֺܴóµÄʱºò£¬¶ÔÐÔÄܵÄÓ°Ïì±ã¿ªÊ¼±äµÃ¿É¹ÛÁË.

Õâ¸öÊý×Ö£¬ÎÒ²éÁËÏÂ×ÊÁÏ£¬¾Ý˵ÊÇ1000ÒÔÏ¿ÉÒÔʹÓÃ$().each·½·¨£¬¶øÕâ¸öÊý×ÖÈç¹û¼ÌÐøÔö¼Ó£¬ÔòÓ¦¸ÃʹÓÃforÑ­»·Óï¾ä¡£
 
¾¡Á¿¼õÉÙ¶ÔDOMµÄ²Ù×÷

¡¡

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

Ïà¹ØÎÄÕÂ
  • 7¸öÓÐÓõÄjQueryС¼¼ÇÉ

    7¸öÓÐÓõÄjQueryС¼¼ÇÉ

    2016-02-26 13:02

  • jQueryÖÆ×÷selectË«ÏòÑ¡ÔñÁбí

    jQueryÖÆ×÷selectË«ÏòÑ¡ÔñÁбí

    2016-02-26 11:00

  • È«ÃæÏêϸµÄjQuery³£¼û¿ª·¢¼¼ÇÉÊÖ²á

    È«ÃæÏêϸµÄjQuery³£¼û¿ª·¢¼¼ÇÉÊÖ²á

    2016-02-26 10:02

  • Ç¿´óµÄjQueryÒƶ¯²å¼þTop 10

    Ç¿´óµÄjQueryÒƶ¯²å¼þTop 10

    2016-02-25 09:05

ÍøÓѵãÆÀ
½