Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

add class to new element js

    const exampleElement = document.createElement('div');

    exampleElement.classList.add("exampleClass");

	const container = document.getElementById('container1');
    container.appendChild(exampleElement);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #class #element #js
ADD COMMENT
Topic
Name
8+5 =