首页 新闻 会员 周边

背景变灰的实现方法

0
悬赏园豆:5 [待解决问题]

怎么实现当一个字段变为true时,某个页面的背景色变为灰色,

灬丶的主页 灬丶 | 初学一级 | 园豆:2
提问于:2016-11-14 15:27
< >
分享
所有回答(2)
0

ajax请求判断

张云山 | 园豆:642 (小虾三级) | 2016-11-14 15:47
0

<!DOCTYPE html>
<html>
<head>
<center>
<p>change color when true</p>
</center>

<script type="text/javascript">
function change()
{
if(document.getElementById("view").innerHTML == "true")
{
document.getElementById("view").innerHTML = "false";
document.getElementById("color").style.background = "#ff00ff";
}
else
{
document.getElementById("view").innerHTML = "true";
document.getElementById("color").style.background = "#00ff00";
}
}
</script>
</head>

<body>
<center>
<div id="color" style="width:450px; height:380px; background:#ff00ff;">
<button id ="view">false</button>
<br>
<button id="action" onclick="change()" >click the button to change status</button>
</div>
</center>
</body>

</html>

wssheng | 园豆:214 (菜鸟二级) | 2016-11-17 18:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册