1

ボタンでページの背景色を変更するコードを実行する方法を見つけようとしています

基本的に、ボタンとその機能のコードを書きましたが、ボタンでページ全体の色を変更するために使用するコードを理解するのに苦労しています

<script>
    function changeColor()
    {

    };
    function changeText()
    {
        alert ("change text in this part");
    };
    function sendMsg()
    {
        alert ("change msg content here");
    }
</script>

<body>
    <h1>Welcome to my program!</h1>
        <button onclick="changeColor()">Color</button>
        <button onclick="changeText()">Text</button> </br>
            <p>Can I ask you something Ive always wanted to ask the real Batman?</p> </br>
                 <input type="text" name="">
</body>
4

2 に答える 2

1
  document.body.style.background = color;

それ以上のことはありません、それはそれと同じくらい簡単です!

于 2013-04-05T01:37:11.583 に答える