Jump to content

what is proper code: document.getElementById(fretboardContainer).style.backgroundColor =


vmars316

Recommended Posts

Hello & TIA ,

I am trying to change a background color of a <div> backgroundColor with javascript .

#fretboardContainer { background-color: #DCDCDC; 

<button class="button"  id="button2" onclick="button2Clicked()">Color</button>

<table   id="fretboardContainer" style=" position: absolute ; width: 1200px;">

With this code:

<script>
function button2Clicked() {
alert("button2 was clicled") ;
document.body.style.backgroundColor = "red";
document.getElementById(fretboardContainer).style.backgroundColor = "#000000"
}
</script>

This is the culprit: 

document.getElementById(fretboardContainer).style.backgroundColor = "#000000"

Pls , what is the proper way to code that ?

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...