HOW TO ADD AND DELETE CLASS NAME USING JAVASCRIPT DOM MANIPULATION METHODS

HOW TO ADD AND DELETE CLASS NAME USING JAVASCRIPT DOM MANIPULATION METHODS

<!-- HERE WE WILL SEE THE CONCEPT OF ADDING/DELETING A  CLASS BY USING 'ByClassName'  METHOD UNDER DOM MANPULATION METHODS-->


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Test Page</title>
  <script src="main.js"></script>
</head>
<body>

<h1 id="selector" style="border: 2px solid dodgerblue; padding : 2px">RUSTIC TRAVEL JUNKIE</h1>

<p id="para">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum ipsam blanditiis voluptatibus et, cumque expedita, quam ea! Dolorem obcaecati, fuga, culpa neque, repellat laudantium libero sed sint veritatis praesentium vitae cumque ratione eveniet optio, aspernatur ab. Eveniet, quisquam veritatis quo maxime labore nostrum consectetur eaque cumque distinctio vel doloremque sunt unde harum placeat, quam perferendis possimus similique laboriosam repellendus. Ut!</p>

<button onclick = "box()">CLICK ME</button>

<script>

function box(){
  var a  = document.querySelector("#para").className="abc";
  console.log(a);
}


</script>

</body>
</html>


HERE IS THE WORKING CODE OUTPUT:



Comments

Popular posts from this blog