【发布时间】:2018-02-28 14:06:22
【问题描述】:
从下拉列表中选择时,我试图更改 html 页面背景图像(url 图像),但我不知道如何.. 以下是我的代码:
<select id="styledSelect" onchange="doit()">
<option value="0" /> Select...
<option value="1" /> 1
<option value="2" /> 2
<option value="3" /> 3
<option value="4" /> 4
<option value="5" /> 5
<option value="6" /> 6
<option value="7" /> 7
<option value="8" /> 8
<option value="9" /> 9
</select>
<script>
function between(x, min, max) {
return x >= min && x <= max;
}
function doit() {
var s = document.getElementById('styledSelect');
if (between(s.value, 1, 3)) {
[http image1]
}
else if (between(s.value, 4, 6)) {
[http image2]
}
else if (between(s.value, 7, 9)) {
[http image3]
}
}
</script>
【问题讨论】:
标签: html image select background dropdown