How to change the background color using JavaScript?
How to change the background color using JavaScript?
1. To Change the entire web page background color use below code
document.body.style.backgroundColor ="#000"
2. Change the background color of an element using ID
<p id="MyParagraph">Hiiii..How are you?</p>
<script type="text/javascript">
$(window).on("load", function() {
document.getElementById("MyParagraph").style.backgroundColor="red";
});
</script>
-Happy Coding
Comments
Post a Comment