Class 02 notes - Ginsusamurai/seattle-301d58 GitHub Wiki

jQuery

  • use a CDN (content delivery network) to load but drop it in PRIOR to your custom js.
  • jQuery selectors utilize CSS selector notation to query elements
  • data- attribute, just like setAttribute, can create unique data values for developers to use
    • id and class are for designers. data- is for developers to add more meta-data to tags
  • jQuery can only add a listener on an element that currently exists and will NOT update ones created after
  • EVENT DELEGATION -> add a listener to a parent object and have THAT listen for the children to have their events triggered
    • $('ul li).on('click', callback) becomes `$('ul').on('click', 'li', callback)
    • $('parent').on('event', 'child', callback)
  • Ajax -> runs queries on the internet
    • $.ajax('http://google.com') => gets data from google
    • $.ajax('path/to/file') => local path
    • $.ajax('/filepath', {method: "GET", dataType: "JSON}).then(data => //do the thing)