JQuery Quiz Questions Flashcards
What is jQuery?
A library of code that uses someone else’s code
What is the jQuery selector function?
$
What does the jQuery selector function return?
An object
Why would someone use jQuery over vanilla Javascript?
For older code/ older browsers
What are some downsides from using jQuery over vanilla Javascript?
JQuery loads a ton of code to run a little bit of code. Also relying on a library can be bad
Why do we use the tag at the bottom of the body, instead of putting it inside the tag?
The html doc loads from top to bottom so if the script is in the top it won’t apply the script to the html elements below it
How do you get the text out of an HTML element?
.text() method
How do you get the value out of an HTML input field?
.val() method
What’s the difference between .text() and .html()?
Its similar to innerHtml and textContent. Just like innerHtml, you don’t want to use the .html()
What does .on() do?
Attaches an event handler function for one or more events to the selected elements
How does ajax work?
By giving it an object literal with the proper methods so that we can get back info
Why did we need the jQuery CDN?
To get the proper methods
How do you specify the request method (GET, POST, etc.) when calling ajax?
Specify the method property on the object
Why might you need to build elements dynamically with data from an AJAX request?
Because we need to wait for data to come in and then create elements dynamically when the data is received
Should you use named functions or anonymous functions for success and error handlers?
Named functions so they can be referenced later