Created
October 11, 2015 21:04
-
-
Save tylucaskelley/ba0ffe8a2941648c152a to your computer and use it in GitHub Desktop.
Udacity jQuery Webcast: Examples of Using the "$" function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { // ensure jQuery is loaded before doing anything | |
// iterate over an array | |
$.each([1, 2, 3, 4], function(index, value) { | |
console.log( index + ": " + value ); | |
}); | |
// parse a JSON-formatted string and return a JS object | |
var obj = $.parseJSON('{ "first_name": "Ty-Lucas", "last_name": "Kelley" }'); | |
// get some JSON from an API | |
$.get("/api/v0/users.json", function(data) { | |
console.log(data); | |
}); | |
// There are tons of other utilities that jQuery makes available via the "$" function! | |
// Read about them here: https://api.jquery.com/category/utilities/ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment