All ements ka color change

 <!DOCTYPE html>

<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>replit</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
  <h1>This is this function in dom</h1>
  <h2>lets do parctice</h2>
  <h3> lets get start</h3>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Excepturi quos architecto nemo asperiores atque impedit. Nihil, deleniti? Obcaecati perferendis minus ratione voluptates deleniti, laudantium inventore unde possimus deserunt aliquam nemo.</p>
<button>click me</button>
  <script src="index.js"></script>
</body>

</html>


--------------------------------------------------------------------

let btn = document.querySelector("button")
let p = document.querySelector("p")
let h1 = document.querySelector("h1")
let h2 = document.querySelector("h2")
let h3 = document.querySelector("h3")

function changeColor() {
    console.log(this.innerText);
    this.style.backgroundColor = "blue"
}



btn.addEventListener("click", changeColor)

p.addEventListener("click", changeColor)

h1.addEventListener("click", changeColor)

h2.addEventListener("click", changeColor)

h3.addEventListener("click", changeColor)


Comments

Popular posts from this blog

practice test of Arithmetic Operations: