Use Element.parentNode to get the given element’s parent node. Use Element.removeChild() to remove the given element from its parent node.
Miscellaneous
Create a one time event handler
When attaching a handler to a given event, you can pass { once: true } to the last parameter of the addEventListener method.
Get the value of a query string from a URL
Here’s a simple method you can use to get the value of a query string with native JavaScript.
Check if the given argument is a string
Use typeof to check if a value is classified as a string primitive.
Detect Internet Explorer browser
Check if the current browser is Internet Explorer (IE).
Check if the given number falls within the given range
Use arithmetic comparison to check if the given number is in the specified range.
Get all siblings of an element
A simplified approach using some ES6 methods.
Check if two arrays or objects are equal
A robust way to compare two arrays (or objects) and check if they’re equal to each other.
Prevent the default action of an event
Use the preventDefault() method. This method works with inline attribute.
Get Siblings of an Element
This snippet gets the next sibling and previous sibling of an element, using the element.nextSibling and element. previousSibling properties.