Jquery Flashcards
What is jQuery?
A javascript library that adds functionality
What is the jQuery selector function?
the $ sign
What does the jQuery selector function return?
returns a jQuery object
Why would someone use jQuery over vanilla Javascript?
cross-browser compatibility,
What are some downsides from using jQuery over vanilla Javascript?
Need to load the massive jQuery library every time.
Why do we use the < script > tag at the bottom of the body, instead of putting it inside the < head > tag?
HTML document loads from top to bottom
How do you get the text out of an HTML element?
.html() or .text() method
How do you get the value out of an HTML input field?
.val() method
What’s the difference between .text() and .html()?
html() retrieves data from only the first element of that matched name
text() retrieves data from all elements of the given element name
What does .on() do?
adds an event listener
What is event bubbling?
The way in which nested events are handled. The order flow goes from most specific to least specific ->
child to parent
What is the difference between event.target and event.currentTarget.
event.target is element that triggered the event.
currentTarget is the element the eventhandler is attached to
What is the first argument the function setTimeout takes?
a function to be called after the timer
If the second argument is not passed into the setTimeout function, what is the default value?
0
What are some scenarios where setTimeout can be useful?
countdowns, game clocks, etc