element.classList.contains(className); // CHECKS if the element has a class(classname)
elements[i].classList.toggle("selected"); // toggles a class on and off in this case in a for loop
var circle = document.createElement("p"); // creates an element
window.addEventListener("beforeunload", function (e) { // to add function when closing the tab or being redirected
var confirmationMessage = "\o/";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome
});
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter