【发布时间】:2012-02-19 22:10:39
【问题描述】:
我已经接近答案了,但我在 jQuery 方面还不够好,无法对其进行调整以达到我想要的方式。
I need to change the css class of a div when a select option is selected.
所以如果代码是:
<style>
.red{
background-color:red;
}
.green{
background-color:green;
}
.blue{
background-color:blue;
}
</style>
<html>
<div id="box"> </div>
<select>
<option value=1>Red</option>
<option value=2>Green</option>
<option value=3>Blue</option>
</select>
</html>
在选择适当的选项时,我将如何更改“#box”的背景颜色?
THIS 如此接近。 (Found here)
【问题讨论】:
标签: jquery css select background option