用html设置两个按钮。分别是红蓝两种颜色。点击按钮来背景变成相应的颜色。求大神解答。在线等。很!

用html设置两个按钮。分别是红蓝两种颜色。点击按钮来背景变成相应的颜色。求大神解答。在线等。很!,第1张

<html>

    <head>

        <title>demo page</title>

    </head>

    <body>

        <input type="button" value="red" onclick ="set_bg_red()" />

        <input type="button" value="blue"  onclick = "set_bg_blue()"/>

        <script>

            function set_bg_red(){

                document.bgColor="#ff0000"

            }

            function set_bg_blue(){

                document.bgColor="#0000ff"

            }

        </script>

    </body>

</html>

<button onclick="this.style.backgroundColor=='red'?this.style.backgroundColor='':this.style.backgroundColor='red'" >确定</button>

radio是指单选按钮,html中的radio是无法改变改变样式跟颜色的。

这是由系统决定的,任何人也改变不了它的样式跟颜色。

普通按钮可以变,单选按钮是无法变的。

html:

超文本标记语言,标准通用标记语言下的一个应用。

超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素。

超文本标记语言的结构包括“头”部分(英语:Head)、和“主体”部分(英语:Body),其中“头”部提供关于网页的信息,“主体”部分提供网页的具体内容。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/8361237.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-15
下一篇2023-04-15

发表评论

登录后才能评论

评论列表(0条)

    保存