Javascript shortcuts

PHOTO EMBED

Wed Mar 16 2022 14:34:23 GMT+0000 (Coordinated Universal Time)

Saved by @patdevwork

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
});
content_copyCOPY