HTML:
<div id="theme">
<span>Theme:</span>
<select onchange="getval(this);">
<option value="blue">Blue</option>
<option value="red">Red</option>
</select>
</div>
<h1>Hello</h1>
JavaScript:
function getval(sel) {
var x = sel.value;
if(x = 'red')
{
alert('i am red');
$('h1').css('border-bottom-color', 'red');
}
if(x = 'blue')
{
alert('i am blue');
$('h1').css('border-bottom-color', '#1d6094');
}
}
CSS:
h1{
border-bottom: 5px solid #1d6094;
margin-bottom: 10px;
width: auto;
line-height: 100%;
font-family: Arial;
}
我不明白为什么当我在下拉菜单中将颜色从红色更改为蓝色时,h1 css 没有改变。也许案例陈述可以解决我的问题?