Last active
July 19, 2016 18:18
-
-
Save israeljrs/eeb0eba7662dc875e6d833b603390495 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Fade an element out and then remove it | |
var s = document.getElementById('thing').style; | |
s.opacity = 1; | |
(function fade(){(s.opacity-=.1)<0?s.display="none":setTimeout(fade,40)})(); | |
//Make an AJAX call | |
var r = new XMLHttpRequest(); | |
r.open("POST", "path/to/api", true); | |
r.onreadystatechange = function () { | |
if (r.readyState != 4 || r.status != 200) return; | |
alert("Success: " + r.responseText); | |
}; | |
r.send("banana=yellow"); | |
// add class to button with vanilla.js. | |
// using the animate.css. | |
document.querySelector('button').addEventListener('click',function(e){ | |
e.preventDefault(); | |
document.querySelector('div').classList.add('dance'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment