jQuery Flashcards
What is jQuery?
A open source library of JS code
What is the jQuery selector function?
jQuery() or $()
What does the jQuery selector function return?
jQuery object with reference to element
Why would someone use jQuery over vanilla Javascript?
Faster and less code to type
** cross browser compatibility
What are some downsides from using jQuery over vanilla Javascript?
Huge library to import
People become too reliant on jQuery and can’t do more complicated DOM manipulations with regular JS
Why do we use the tag at the bottom of the body, instead of putting it inside the <head> tag?
HTML elements need to load first before the JS can run and manipulate them
How do you get the text out of an HTML element?
.text()
How do you get the value out of an HTML input field?
.val()
What’s the difference between .text() and .html()?
** .text - returns only text content** use this
.html - returns html elements
How does ajax work?
- give it an object literal with relevant data with destination, how we’re sending data, how we’re getting it back
Why did we need the jQuery CDN?
Because ajax uses jQuery methods
How do you specify the request method (GET, POST, etc.) when calling ajax?
Under method property
Why might you need to build elements dynamically with data from an AJAX request?
When we get data can populate information on a webpage with the data received from the request
Should you use named functions or anonymous functions for success and error handlers?
Named functions, have ways to reference them later
syntax of config options shorter