change colors of table with javascript

后端 未结 2 663
北海茫月
北海茫月 2021-01-29 08:29

I\'m trying to study for my exam and I thought I was doing this right... I want to change the color of the table (font or background) depending on which cell you click I thought

相关标签:
2条回答
  • 2021-01-29 09:09

    Setting backgroundColor is correct, but what's going on with font.color? Where did that come from?

    Just use style.color.

    Also, fix the typo "get�El�ementById" in the second one.

    0 讨论(0)
  • 2021-01-29 09:20

    Change getLementbyId and getElementbyId to getElementById and change font.color to color.

            function changeFont(color){
                document.getElementById("miTabla").style.color = color;
            }
            function changeBack(color){
                 document.getElementById("miTabla").style.backgroundColor = color;
            }
    

    changeFont might also be more appropriately named changeForeground.

    0 讨论(0)
提交回复
热议问题