â
ãjQueryã jQuery(1.4.2)ã®ã½ã¼ã¹ãå°ãèªããªã©
- jQueryã®ã½ã¼ã¹èªã¿ãªã©
- ãªãã¨ãªãå®è¡(ver 1.4.2)
- æ¦è¦æ´ããããã®æãã§
- 6000è¡ãããã(ã¾ã6241è¡ã§ããã©ãã)
for loopã®ãã¯ã¨ã
- ã¾ãJsã§ã¯è¯ã使ããã¯ããã¯ãæ£è¦ããã
- ä¾ãã°ä¸è¨ã®inArrayã³ã¼ãã®for ( var i = 0, length = array.length; i < length; i++ )ã£ã¦é¨å
- ã¡ãªã¿ã«jQuery cook bookã¨ãã ã¨eachã¤ããããforã§åãã»ããéãã®ã§å¦çéãããéã«ã¯ããããçãªãã¨ãæ¸ãã¦ããã
- ãã¨ãi++ãã++iã®ããã©ã¦ã¶ã«ãã£ã¦ã¯éããªãã¨ã,htmlãã[0].innerHTMLã®ãDOM Updateãéããªãã¨ãããäºãjQuery Cook Bookã«æ¸ãã¦ããããã
inArray: function( elem, array ) { if ( array.indexOf ) { return array.indexOf( elem ); } for ( var i = 0, length = array.length; i < length; i++ ) { if ( array[ i ] === elem ) { return i; } } return -1; },
splitãã¯ã¨ã
- ä½ãããã®å¦çãä¸æ°ã«ããã¨ãã«ä½¿ã
- ä¸æ°ã«evnent bindingãããããã¨ãã«ä½¿ã£ãã
- Ajax Event handler attachããã¨ãã«ä½¿ã£ãã
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup error").split(" "), function( i, name ) { // Handle event binding jQuery.fn[ name ] = function( fn ) { return fn ? this.bind( name, fn ) : this.trigger( name ); }; if ( jQuery.attrFn ) { jQuery.attrFn[ name ] = true; } });
ajaxé¢é£ãªã©(bind bind)
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) { jQuery.fn[o] = function( f ) { return this.bind(o, f); }; });
Ajaxå¨ãã®é¢æ°ã®å®è£ ãªã©
- get: å é¨ã§jQuery.Ajaxå©ç¨
- getScript å é¨ã§jQuery.getå©ç¨
- getJSON: å é¨ã§jQuery.getå©ç¨
- post: å é¨ã§jQuery.Ajaxå©ç¨
- load: å é¨ã§jQuery.Ajaxå©ç¨
global objectã¨ãã¦ã®jQueryã®ç»é²
- ã¾ã以ä¸ã®ãããªæãã§
// Expose jQuery to the global object window.jQuery = window.$ = jQuery;
queueã¨ãdequeueã®å®è£
ã¨ã
- overrideã§å®è£ (è¤æ°ãã)
firstã¨ãlastã¨ã
- selectorã¨ãã¯åç´ã«eq(0)ã¨ãeq(-1)ã§åå¾ãã¦ã
first: function() { return this.eq( 0 ); }, last: function() { return this.eq( -1 ); },
IEé¢é£ã®å¯¾å¿å®è£ ã¨ã
- ãã£ããã½ã¼ã¹ã³ã¼ããé·ããªã£ã¦ãã®ã¯IEå¨ãã®å¯¾å¿ãåå ã¨ããç¯(ã¾ãããã»ã©å¤ãã¨ããããã§ããªãã£ãããã)
ä¾1: IEã§ã®DOMæºåå¤å®ã¨ã
// The DOM ready check for Internet Explorer function doScrollCheck() { if ( jQuery.isReady ) { return; } try { // If IE is used, use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ document.documentElement.doScroll("left"); } catch( error ) { setTimeout( doScrollCheck, 1 ); return; } // and execute any waiting functions jQuery.ready(); }
ä¾2: Ajaxã®ã¢ã¬ã¨ã
// Create the request object; Microsoft failed to properly // implement the XMLHttpRequest in IE7 (can't request local files), // so we use the ActiveXObject when it is available // This function can be overriden by calling jQuery.ajaxSetup xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ? function() { return new window.XMLHttpRequest(); } : function() { try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} },
IEç¨ã¡ã¢ãªãªã¼ã¯å¯¾çã¨ã
// Prevent memory leaks in IE // Window isn't included so as not to unbind existing unload events // More info: // - http://isaacschlueter.com/2006/10/msie-memory-leaks/ if ( window.attachEvent && !window.addEventListener ) { window.attachEvent("onunload", function() { for ( var id in jQuery.cache ) { if ( jQuery.cache[ id ].handle ) { // Try/Catch is to handle iframes being unloaded, see #4280 try { jQuery.event.remove( jQuery.cache[ id ].handle.elem ); } catch(e) {} } } }); }
jQuery.fn.extendã¨ãjQuery.extendã¨ã
- é¢æ°ãªã©ãããéã«ã¯jQuery.fn.extendã¨ãjQuery.extendãå©ç¨ãã
- å®è£ ã¯ä»¥ä¸ã®ãããªæã?(éä¸çç¥)
// Give the init function the jQuery prototype for later instantiation jQuery.fn.init.prototype = jQuery.fn; jQuery.extend = jQuery.fn.extend = function() {...
è¬ãªé¨å.ãã©ã¦ã¶ã®Jså®è£ ã«å¿ãã¦ããã£ã¦ãå¤ã®æ±ããå¤æ´ããããããã£ã½ã?
// Here we check if the JavaScript engine is using some sort of // optimization where it does not always call our comparision // function. If that is the case, discard the hasDuplicate value. // Thus far that includes Google Chrome. [0, 0].sort(function(){ baseHasDuplicate = false; return 0; });
Sizzle.jsã®å©ç¨
ã¾ããã£ã¨ã½ã¼ã¹è¦ãã ãã ã£ãã.