use*_*102 7 css multi-select html.dropdownlistfor
我想在多选下拉框中为所选项目指定黄色.默认情况下,选择后它有灰色背景,我想这样做HTML, CSS.
任何人都可以帮忙吗?
小智 6
我们可以简单地借助以下 CSS:
select option:checked{
background: #1aab8e -webkit-linear-gradient(bottom, #1aab8e 0%, #1aab8e 100%);
}
Run Code Online (Sandbox Code Playgroud)
我们可以使用 JS 来选择 DOM。
$('select').change(function() {
$('option').css('background', 'none');
$('option:selected').css('backgroundColor', 'red');
}).change()
<select>
<option>1111111</option>
<option>222222222</option>
<option>33333333</option>
<option>44444444</option>
</select>
Run Code Online (Sandbox Code Playgroud)
演示: http: //jsfiddle.net/TxbVt/1/