Skip to content

Instantly share code, notes, and snippets.

@lizkaraffa
Created January 17, 2014 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizkaraffa/8467936 to your computer and use it in GitHub Desktop.
Save lizkaraffa/8467936 to your computer and use it in GitHub Desktop.
I've been studying jQuery from two different sources and I understand the longer syntax structure of source A but I want to get familiar with how to chain things like in source B.
//Source A shows this syntax as the proper way to write all jQuery code.
$(document.ready(function(){
$('thingToInteractWith').event(function(){
$('thingToAffect').effect();
});
});
//Another example below
$(document.ready(function(){
$('div').click(function(){
$('this').fadeOut('slow');
});
});
/*Source B has an example of their jQuery code shown below.
I'm finding that I don't know with the same certainty what these codes do (because of their syntax) as I do with the above code from Source A
Additionally, Source A pretty much always assumes you'll have a separate javascript sheet, whereas everything from Source B is written on index.html between <script></script> tags.
*/
$(this).next().show('slow').prev().remove();
/* I understand that in source A it's only really doing one thing, whereas Source B is doing several things, but I feel like I'm missing the Eureka piece to chain things comfortably. Any ideas?
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment