Table of contents
No headings in the article.
Here i will demonstrate a simple program to how to change the background color of any web page .
Html code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dom project</title>
<!-- ./ lagane se koe bhi stsyem m problem cretae nhi hoti use krni chhaiye -->
<link rel="stylesheet" href="file.css">
</head>
<body>
<button id="button">press to change</button>
<script src="filename.js"></script>
</body>
</html>
CSS code:
body{
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
/* // from the above two statements we can bring the content to the center of the web page */
}
button{
padding: 22px;
font-size: 18px;
border-radius: 24px;
background-color: blanchedalmond;
}
JavaScript code:
const btn = document.getElementById("button")
const randomColoor=()=>
{
let val = "0123456789ABCDEF";
let constan = "#"
for(let i = 0;i<6;i++)
{
constan = constan+val[Math.floor(Math.random() * 16)]
}
return constan;
};
// console.log(randomColor())
function changerandomcolr()
{
document.body.style.backgroundColor= randomColoor();
}
btn.addEventListener("click",changerandomcolr)
lt.36 link: https://hashnode.com/post/clvfiis57001f0al8aqgl28xb