Change text color with Javascript?

后端 未结 5 2103
执念已碎
执念已碎 2020-12-06 11:02

I want to change the color of a title when a button is clicked. This is my code, but it\'s not working and I can\'t figure out why not...

5条回答
  •  眼角桃花
    2020-12-06 11:51

    use ONLY

    function init() { 
        about = document.getElementById("about");
        about.style.color = 'blue';
    }
    

    .innerHTML() sets or gets the HTML syntax describing the element's descendants., All you need is an object here.

    Demo

提交回复
热议问题