jQuery¼¼Êõ

µÚ¶þÕ jQuery¼¼Êõ½âÃÜ (Èý)(3)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-11-11 11:32 ÎÒÒªÆÀÂÛ( )

(3) µÚÈý²½£¬Èç¹ûµÚÒ»¸ö²ÎÊýÊǺ¯Êý£¬ÔòµÚ¶þ¸ö²ÎÊý¿ÉÑ £ËüÊÇ $(document).ready(fn) ÐÎʽµÄ¼òд£¬return jQuery(document)[jQuery.fn.ready? ready: load](selector) ÊÇÆäÖ´ÐеĴúÂë¡£¸ÃÓï¾äÏÈÖ´ÐÐ jQuery(document)

(3) µÚÈý²½£¬Èç¹ûµÚÒ»¸ö²ÎÊýÊǺ¯Êý£¬ÔòµÚ¶þ¸ö²ÎÊý¿ÉÑ¡¡£ËüÊÇ $(document).ready(fn) ÐÎʽµÄ¼òд£¬return jQuery(document)[jQuery.fn.ready? "ready": "load"](selector) ÊÇÆäÖ´ÐеĴúÂë¡£¸ÃÓï¾äÏÈÖ´ÐÐ jQuery(document) £¬ÔÙͨ¹ý new jQuery.fn.init() ·½Ê½´´½¨ jQuery ¶ÔÏ󣬴ËʱԪËØΪ document ¡£ÔÙµ÷ÓÃÕâ¸ö¶ÔÏóµÄ ready() ·½·¨£¬²¢·µ»Øµ±Ç°µÄ jQuery ¶ÔÏó¡£

$(document).ready(fn) ÊÇʵÏÖ domReady µÄ jQuery ¶ÔÏóµÄͳһÈë¿Ú£¬¿ÉÒÔͨ¹ý $(fn) ×¢²á domReady µÄ¼àÌýº¯Êý¡£ËùÓеĵ÷Óà jQuery ʵÏÖ¹¦ÄܵĴúÂ붼Ӧ¸ÃÔÚ domReady Ö®ºó²ÅÄܹ»ÔËÐС£$(fn) ÊÇËùÓÐÓ¦Óÿª·¢ÖеŦÄÜ´úÂëµÄÈë¿Ú£¬ËüÖ§³ÖÈÎÒâ¶àµÄ $(fn) ×¢²á¡£

(4) µÚËIJ½£¬Èç¹ûµÚÒ»¸ö²ÎÊýÊdzý DOM ÔªËØ¡¢º¯ÊýºÍ×Ö·û´®Ö®ÍâµÄËùÓÐÆäËûÀàÐÍ£¬Ò²¿ÉÒÔΪ¿Õ (Èç$())£¬¶øµÚ¶þ¸ö²ÎÊý¿ÉÑ¡¡£µ÷Óà return this.setArray(jQuery.makeArray(selector)); ½øÐд¦Àíʱ£¬ËüÏÈÊǰѵÚÒ»¸ö²ÎÊýת»»ÎªÊý×é¡£µ±È»Õâ¸ö²ÎÊý¿ÉÒÔÊÇÀàÊý×é½á¹¹µÄ¼¯ºÏ£¬Èç jQuery ¶ÔÏó¡¢getElementsByTag ·µ»ØµÄ DOM ÔªËؼ¯ºÏµÈ£¬¿ÉÖ§³Ö $(this) ¡£selector »¹¿ÉÄÜÊǵ¥¸öÈÎÒâ¶ÔÏó£¬×ª»»³É±ê×¼µÄÊý×éÖ®ºó£¬Ö´ÐÐ this.setArray °ÑÕâ¸öÊý×éÖеÄÔªËØÈ«²¿´æ´¢µ½µ±Ç°µÄ jQuery¶ÔÏ󼯺ÏÖУ¬²¢·µ»Ø jQuery ¶ÔÏó¡£

¡¡

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

Ïà¹ØÎÄÕÂ
  • jquery³£Óü¼Êõ×ܽá

    jquery³£Óü¼Êõ×ܽá

    2017-11-11 11:33

  • ÿÈÕѧϰÐĵãº$.extend()·½·¨ºÍ(function($){...})(jQuery)Ïê½â

    ÿÈÕѧϰÐĵãº$.extend()·½·¨ºÍ(function($){...})(jQuery)Ïê½â

    2017-11-10 18:05

  • jQueryµÄ¶¹°êAPI²å¼þ jQuery Douban

    jQueryµÄ¶¹°êAPI²å¼þ jQuery Douban

    2017-11-10 18:00

  • jQuery»ù´¡Ñ§Ï°±éÀú closest()·½·¨

    jQuery»ù´¡Ñ§Ï°±éÀú closest()·½·¨

    2017-11-09 14:01

ÍøÓѵãÆÀ
<