Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript add class

<p id="id1">Javascript adds a CSS class to this paragraph.</p>

<script>
  // Get the element with id="id1"
  const element = document.getElementById("id1");
  
  // Add a class
  // METHOD 1
  element.classList.add("quote");
  
  // METHOD 2
  element.className += "box";
</script>
Source by www.tutorialstonight.com #
 
PREVIOUS NEXT
Tagged: #javascript #add #class
ADD COMMENT
Topic
Name
6+2 =