summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKamil Kaminski <kylek389@gmail.com>2014-11-29 14:58:11 -0600
committerKamil Kaminski <kylek389@gmail.com>2014-11-29 14:58:11 -0600
commit5dd842c573e00fb9f527d04b73937d7908f3b464 (patch)
treee064a79961e878ee426c56ea180bb50914b4605b
parentb40d19044568166aa01a9f3cadcd371358a91364 (diff)
downloadwebsandbox-master.tar.gz
websandbox-master.tar.bz2
websandbox-master.zip
piled up stuffHEADmaster
-rw-r--r--notes.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/notes.txt b/notes.txt
index 0780aa6..52399af 100644
--- a/notes.txt
+++ b/notes.txt
@@ -1,7 +1,12 @@
[jquery]
+- learn here
+ -> http://learn.jquery.com/
+
- $(function() {} is same as $(document).ready(function() {},
$(window).load(function () {} comes later in rendering process when all
tags are ready such as images
+ -> DOM way, in case jQuery hasn't loaded yet and is undefined, e.g. jQuery gets loaded in footer
+ - https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded
- stop the default action
e.g. you have an anchor and register a listener for a .click() event using
@@ -9,3 +14,23 @@
event.preventDefault(); /* prevent href from doing its job */
return false; /* stops bubbling up */
+
+- the $() is a constructor call, $ is a variable name, js doesn't prepend var names with $
+ -> find() is similar, and can be chained
+
+- very common jquery uses
+ -> you make a selection using $('your search') and you wonder what you got back
+ - you loop with .each(function {});
+ - use .length, http://learn.jquery.com/using-jquery-core/faq/how-do-i-test-whether-an-element-exists/
+ e.g. if ($('$foo').length) /* heck yeah */ ;
+
+- useful api funtions
+ -> trigger(), e.g. you want to click event to happen on some element at your will,
+ exmaple: ('div.clips a:first').trigger('click');
+ -> after(), append a new element after current, e.g. $('#foo').after('<div id="bar">hell</div>');
+ -> is(), e.g i used it to check if arr content of arr at some index is empty, below:
+ if (!$(transcripts_divs[ind]).is(':empty')) { /* do something awesome */ }
+ -> walking DOM tree
+ - parent(), parentUntil()
+ - next(), children()
+