javascript change background color
document.body.style.backgroundColor = "yellow";
javascript change background color
document.body.style.backgroundColor = "yellow";
how to change background color using js
var warning = document.getElementById("warning");
warning.style.background-color = "red";
change background color on button click in javascript
<style>
.bg1 {
background-color: red;
}
</style>
<button id="btnChangebgColor" />
<script>
$(document).ready(function(){
$("#btnChangebgColor").click(function() {
$(this).addClass(".bg1");
});
}
</script>
javascript-change color onclick()
const btn = document.querySelector('button');
function random(number) {
return Math.floor(Math.random() * (number+1));
}
btn.onclick = function() {
const rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
document.body.style.backgroundColor = rndCol;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us