JavaScript的网页更改背景颜色按钮 [英] javascript Change page background color with button
本文介绍了JavaScript的网页更改背景颜色按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找出如何做code与一个按钮
改变页面的背景颜色所以基本上我有code为写出一个按钮,它的功能,但即时通讯有问题搞清楚什么code使用使该按钮改变整个页面的颜色
<脚本>
功能changeColor()
{ };
功能changeText()
{
警报(在这部分的变化文字);
};
功能SENDMSG()
{
警报(变味精内容在这里);
}
< / SCRIPT>
<身体GT;
< H1>!欢迎光临我的程序和LT; / H1>
<按钮的onclick =changeColor()>颜色和LT; /按钮>
<按钮的onclick =changeText()>文字< /按钮> < / BR>
< P>我能问你一件事我总是想问真正的蝙蝠侠< / P> < / BR>
<输入类型=文本名称=>
< /身体GT;
解决方案
document.body.style.background =颜色;
有没有更多的它,就这么简单!
I am trying to figure out how to do code for changing the background color of a page with a button
so basically I have the code for a button written out and its function but im having trouble figuring out what code to use to make the button change the color of the entire page
<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>
解决方案
document.body.style.background = color;
There's not much more to it, it's as simple as that!
这篇关于JavaScript的网页更改背景颜色按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文