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
What does the setInterval function return?
an interval ID that identifies itself
What argument does the clearInterval function take?
it takes the return value of setInterval
What are some scenarios where setInterval can be useful?
countdowns, game clocks, etc
What is the event loop?
A separate concurrent queue for code. when the call stack is empty, code in the event loop is pushed to the call stack.
What does the term blocking mean?
something is preventing code in the call stack from running
What is the call stack?
the data structure that arranges the order of actions to be taken by the code
Which elements in a website are useful to create dynamically?
Things that rely on outside data, such as user input
Why should you not create all elements dynamically?
can make your page open to attacks,
What is a modal?
an overlay window with fixed position on the screen
What are some use cases for modals?
something to grab the attention of the user,
Why does a modal usually need to occupy the entire height and width of the viewport?
So that the user cannot click outside the modal area to avoid it
Give two examples of media features that you can query in an @media rule.
width, height
Which HTML meta tag is used in mobile-responsive web pages?
“viewport”