Assignment

 HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Assignment</title>
    <link rel="stylesheet" href="Assignment.css">
  </head>
  <body>
    <div>
    <p>
      This is a demo of mouse events as a paragraph
      :sdagrfsedzrtfrtfrtfrtfrtfrtfgbdhdhdhdhdhdhfnmhjfdgxhfbvtywwwwjmkhfddtjjjjfhdhedtyujhyr
    </p></div>
    <input type="text" />
    <script src="Assignment.js"></script>
  </body>
</html>

CSS

p{
    width: 200px;
    height: 500px;
    border: 1px solid black;
    display: flex;
justify-content: center;
overflow: scroll;}

JS

let inp = document.querySelector("input");
inp.addEventListener("mouseout", function () {
  console.log("Mouse moved");
});


inp.addEventListener("keypress", function () {
  console.log("Key Pressed");
  console.log(this.value);
});




let p = document.querySelector("p");
p.addEventListener("scroll", function () {
  console.log("scrolled...");
});



window.addEventListener("load",function(){
    console.log("window loaded");
})
// Q2
let btn=document.querySelector("button");
btn.addEventListener("click",function(){
    this.style.backgroundColor="green";
});

// Q3
let inp2=document.querySelector("#inp");
let h2=document.querySelector("h2");
inp2.addEventListener("input",function(){
    h2.innerText=inp2.value;
    console.log(inp2.value);
})







Comments

Popular posts from this blog

Callback Hell

TODO list with DOM

Refactoring callback hell code