From 5dd842c573e00fb9f527d04b73937d7908f3b464 Mon Sep 17 00:00:00 2001 From: Kamil Kaminski Date: Sat, 29 Nov 2014 14:58:11 -0600 Subject: piled up stuff --- notes.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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('
hell
'); + -> 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() + -- cgit v1.2.3