Created
September 6, 2012 08:32
-
-
Save 0xqd/3653081 to your computer and use it in GitHub Desktop.
jQuery cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.down = function() { | |
var el = this[0] && this[0].firstChild; | |
while (el && el.nodeType != 1) | |
el = el.nextSibling; | |
return $(el); | |
}; | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get object from index to index | |
$(el); // << return an array of object | |
$(el).slice(from, to); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Collapsable div for web - not sure about mobile | |
https://github.com/danielstocks/jQuery-Collapse/ | |
// Know when new element is created. | |
http://docs.jquery.com/Plugins/livequery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fucking useful \m/ | |
// $(el)[1] only returns text instead of object | |
$(el).eq(index).<whatever jquery function>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
We should use this selector more often since we can separate the part or pack of element, so even if we move the js and html structure later. It still works well | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://api.jquery.com/on/ | |
// this function will auto bind events to the new element in DOM | |
// so you don't have to use it manually. | |
// #GREAT# - This is very nice |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment