The following illustrates how to remove the first option: selectBox.remove (0); Code language: CSS (css) The second way to remove an option is to reference the option by its index using the options collection and set its value to null: selectBox.options [ 0] = null; There are 2 ways to add and remove class using onclick event using the same button. If the class does not exist, it is added. Toggling can be performed with the toggle method. This methods accepts 2 parameters: When set to true, then add the class — which becomes similar to the add method. When set to false, then remove the class — similar to the remove method. In javascript, remove an element is one of the functions for removing the element in the script code using element id with the help of parent node we can remove its child in the element. ; Summary. JavaScript Add Class (In 3 Ways) - tutorialstonight A DOMTokenList representing the contents of the element's class attribute. add Tip: Also see How To Remove A Class. There are 3 popular methods which can be used to insert or add an object to an array. My blog is now totally jQuery-free. If it's present, do nothing. A function returning one or more space-separated class names or an array of class names to be removed. The push() method is used to add one or multiple elements to the end of an array. JavaScript How to Remove a Class from an Element With Vanilla JavaScript Returns true if an element has the specified class otherwise false: addClass: Adds one or more specified classes. Use jQuery removeClass() to Remove CSS Class From Element With jQuery. In our example, the class name is “paragraphClass” and button’s ID is “Button”. In the above code, “p” element is selected and “selected” class is applied only on last “p” element with the help of .last() method and .addClass() method of jQuery.