如何在jsp页面中进行判断,填充背景色
1个回答
展开全部
代码如下,自己可以举一反三:
<html>
<head>
<script type="text/javascript">
function chgBg (bg){
//alert (bg);
bg = String (bg);
document.getElementById("divBody").style.backgroundColor = bg ;
}
</script>
</head>
<body id="divBody">
<select name="改变颜色"
onchange="chgBg(this.options[this.options.selectedIndex].value)">
<option selected="selected">选择颜色</option>
<option value="tomato">红色</option>
<option value="lightblue">蓝色</option>
</select>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function chgBg (bg){
//alert (bg);
bg = String (bg);
document.getElementById("divBody").style.backgroundColor = bg ;
}
</script>
</head>
<body id="divBody">
<select name="改变颜色"
onchange="chgBg(this.options[this.options.selectedIndex].value)">
<option selected="selected">选择颜色</option>
<option value="tomato">红色</option>
<option value="lightblue">蓝色</option>
</select>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询