js怎么设置按钮控制背景颜色
最近身边一些朋友咨询小编关于js实现点击按钮变换背景颜色,说实话小编对这个不太了解,但是小编从网络上整理了相关的资源,大家可以看一下,希望能够帮助到大家!
操作方法
- 01<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>js实现点击按钮变换背景颜色</title><script type="text/javascript">function aa(){document.bgColor="Orange";} 
- 02function change(c){document.bgColor=c;}</script></head> 
- 03<body onload="aa()"><input type="button" value="橙色" onclick="change('Orange')"/><input type="button" value="粉色" onclick="change('pink')"/><input type="button" value="绿色" onclick="change('green')"/> 
- 04<br /><br/></body></html> 
- 05以上就是所有的代码,因为经验的要求,小编给拆分了,大家可以复制在一起使用。 
 赞 (0)
                        
