jQuery¼¼Êõ

jQueryÔ´Âëѧϰ(Ò»)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2016-05-30 16:00 ÎÒÒªÆÀÂÛ( )

jQueryÔ´Âëѧϰ(Ò»)

jQueryµÄºËÐÄÀíÄî

jQuery¿ò¼ÜµÄºËÐľÍÊÇ´ÓHTMLÎĵµÖÐÆ¥ÅäÔªËز¢¶ÔÆäÖ´ÐвÙ×÷

jQueryÔ´ÂëÕûÌå·ÅÔÚÒ»¸öÄäÃûº¯ÊýÖ´ÐÐÖÐ

(function(window,undefined){//ÕâÀïÊÇÐβΠ})(window,undefined);//´«Èëʵ²Î

ÕâÑùдµÄºÃ´¦ÊÇ£ºÔÚÄäÃûº¯ÊýÖж¨ÒåµÄ±äÁ¿ºÍº¯ÊýÔÚÄäÃûº¯ÊýÍⲿ¶¼ÊÇ·ÃÎʲ»µ½µÄ£¬ÔÚÄäÃûº¯ÊýÖÐÌṩ¶ÔÍâ·ÃÎʵĽӿÚ
ÕâÀï°Ñwindowµ±×ö²ÎÊý´«½øÀ´ÊÇÒòΪwindow´¦ÓÚ×÷ÓÃÓòµÄ×¶Ë£¬ËüµÄ²éÕÒËÙ¶ÈÊÇ×îÂýµÄ¡£
ºÃ´¦1£º½«window×÷Ϊʵ²Î´«µÝ¸øÄäÃûº¯ÊýµÄÐβΣ¬ÔÚÄäÃûº¯ÊýÖпÉÒÔ¼Ó¿ìwindowµÄ²éÕÒËÙ¶È
ºÃ´¦2£ºÔÚѹËõ°æ±¾ÖÐwindow×÷Ϊʵ²Î´«µÝ¸øÄäÃûº¯ÊýµÄÐβÎe£¬Í¨¹ýÕâÑù´«µÝ£¬ÎÒÃÇÖªµÀÔÚѹËõ´úÂëÖÐe¾Í´ú±íÁËwindow
´«Èëundefined£¬ÊÇÒòΪÔÚÄäÃûº¯ÊýÍⲿundefined¿ÉÄܱ»ÐÞ¸ÄΪÆäËûÖµ£¬½«undefined×÷Ϊ²ÎÊý´«½øÀ´£¬ÔÚÄäÃûº¯ÊýÖÐÓõ½undefinedÁ˾ÍÊÇÓõĴ«½øÀ´µÄÖµ¶ø²»»áÏòÍâ²éÕÒÁË¡£

·½·¨ºÍÊôÐÔ jquery

ÓÃÀ´Êä³öÏàÓ¦µÄ°æ±¾ºÅ£º

<script type="text/javascript"> alert($().jquery);//µ¯³ö°æ±¾ºÅ </script> constructor <script type="text/javascript"> { } Person.prototype.name = "lisi"; Person.prototype.age = 20; var person1 = new Person(); alert(person1.constructor);//Êä³öÏàÓ¦µÄ¹¹Ô캯Êý /* function Person(){ } */ </script> <script type="text/javascript"> { } Person.prototype = {//ÕâÀïÊÇÖØдÁËÔ­ÐÍ£¬ÕâÑù¹¹Ô캯ÊýÖ¸Ïò¾Í³öÏÖÁËÎÊÌ⣬ÐèÒªÊÖ¶¯È¥ÐÞÕý constructor:Person, name:"lisi", age:20 } var person1 = new Person(); alert(person1.constructor); /* function Object(){ [native code] } */ </script> jQuery¶ÔÏóתΪdom¶ÔÏó <script type="text/javascript"> console.log($("li"));//jQuery.fn.init[3],ÿ¸öli¶¼ÓжÔÓ¦µÄϱê $("li")[1].style.background = "#f00";//$("li")[1]ÕâÑù¿ÉÒÔ°ÑjQueryת»¯Îªdom¶ÔÏó </script> parseHTML

jQuery.parseHTMLÓÃÀ´½«×Ö·û´®×ª»¯ÎªÊý×é,·µ»ØÒ»¸öÊý×é

<script type="text/javascript"> $(str = '<li>1</li><li>2</li><li>3</li>'; var arr = jQuery.parseHTML(str); console.log(arr);//[li, li, li] $.each(arr,function(i){ $("ul").append(arr[i]); }); }); </script> merge script type="text/javascript"> $(arr1 = ['a','b']; var arr2 = ['c','d']; var arr3 = { 0:'a', 1:'b', length:2 }; //$.mergeÓÃÀ´ºÏ²¢Êý×é console.log($.merge(arr1,arr2));console.log($.merge(arr3,arr2));//Object {0: "a", 1: "b", 2: "c", 3: "d", length: 4} }); </script> ÕýÔòÆ¥Åä <script type="text/javascript"> var rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/; var str1 = '#div1'; var str2 = '<li>hello'; console.log(rquickExpr.exec(str1));//["#div1",undefined,'div1']; console.log(rquickExpr.exec(str2));//["<li>hello", "<li>", undefined] </script> makeArray >2=> <script type="text/javascript"> var oDiv=document.getElementsByTagName("div"); /* oDivÖ»ÊÇÒ»¸öÀàÊý×飬²¢²»ÊÇÕæÕýµÄÊý×飬ÀàÊý×é²»Äܵ÷ÓÃÊý×éµÄ·½·¨ ÔÚjQueryÖпÉÒÔͨ¹ýmakeArray·½·¨½«ÀàÊý×éתΪÕæÕýÊý×é */ console.log(oDiv);//HTMLCollection[div, div, div] console.log($.makeArray(oDiv));//[div, div, div] ±äΪÊý×é console.log($.makeArray(oDiv,{length:0}));// Object { 0=div, 1=div, 2=div, ¸ü¶à...} ±äΪjsonÐÎʽ </script> </body> pushStack pushStack():JQ¶ÔÏóµÄÈëÕ» Õ»ÊǺó½øÏȳö£¬ËùÒÔÕâÀïspanµÄ±³¾°ÑÕÉ«±äºì ¶ÓÁÐÊÇÏȽøÏȳö end() ½øÐгöÕ»²Ù×÷£¬À´·µ»ØÕ»ÖеÄÇ°Ò»¸ö״̬ > =>pushStack> => <script type="text/javascript"> $(function(){ $('div').pushStack($('span')).css('background','red'); //end() ½øÐгöÕ»²Ù×÷£¬À´·µ»ØÕ»ÖеÄÇ°Ò»¸ö״̬,ËùÒÔdiv±³¾°±ä»ÆÁË $('div').pushStack($('span')).css('background','red').end().css('background','yellow'); }); > >1111111>1111111=> <script type="text/javascript"> $($('div').slice(1,3).css('background','red').end().css('color','blue'); }); </script> </body> map

¡¡

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

Ïà¹ØÎÄÕÂ
  • Jquery »ù´¡Ñ§Ï°±Ê¼Ç

    Jquery »ù´¡Ñ§Ï°±Ê¼Ç

    2016-05-26 13:01

  • jquery¶ÔÏóºÍJavaScript¶ÔÏó¼´DOM¶ÔÏóÏ໥ת»»

    jquery¶ÔÏóºÍJavaScript¶ÔÏó¼´DOM¶ÔÏóÏ໥ת»»

    2016-03-06 17:00

  • javascript cookieµÄ¼òµ¥Ó¦ÓÃ

    javascript cookieµÄ¼òµ¥Ó¦ÓÃ

    2016-02-29 11:36

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

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

    2016-02-26 13:02

ÍøÓѵãÆÀ
ã