Skip to content

Instantly share code, notes, and snippets.

@flexbox
Last active November 22, 2017 10:39
Show Gist options
  • Save flexbox/12ce1193465b9df61eccfe19273b2841 to your computer and use it in GitHub Desktop.
Save flexbox/12ce1193465b9df61eccfe19273b2841 to your computer and use it in GitHub Desktop.
How I’m (Not) Using jQuery – http://youmightnotneedjquery.com/
//https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
fetch('/data.json')
.then(res => res.json())
.then(res => {
// res is my data
});
$("#listOfProducts").on("click", ".productThumb", function() {
// STUFF
});
document.addEventListener('click', function(e) {
if(e.target.className !== 'editLink') return;
e.preventDefault();
// STUFF
}, false);
let $field1 = document.querySelector('#field1');
let $field2 = document.querySelector('#field2');
// https://api.jquery.com/ready/
$(document).ready(function() {
// STUFF HERE
});
// https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded
document.addEventListener('DOMContentLoaded', function() {
// STUFF HERE
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment