Skip to content

Instantly share code, notes, and snippets.

@tylucaskelley
Created October 11, 2015 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylucaskelley/ba0ffe8a2941648c152a to your computer and use it in GitHub Desktop.
Save tylucaskelley/ba0ffe8a2941648c152a to your computer and use it in GitHub Desktop.
Udacity jQuery Webcast: Examples of Using the "$" function
$(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