<select id="xl1" onchange="change()" >
<option >第一</option>
<option>第二</option>
</select>
<select id="xl2" onchange="change()" >
<option >第一</option>
<option>第二</option>
</select>
如果只有选择id=xl1中的“第二”才能显示出来id=xl2中的<select>我改怎么做?
我没分,我不过真是再这里卡住了,谢谢各位
JS,<option>a</option>,a的值怎么取。
答案:2 悬赏:50 手机版
解决时间 2021-01-04 00:15
- 提问者网友:孤凫
- 2021-01-03 14:06
最佳答案
- 五星知识达人网友:雪起风沙痕
- 2021-01-10 04:57
<script type="text/javascript">
(function() {
var xl1,xl2
window.onload = function() {
xl1 = document.getElementById("xl1");
xl2 = document.getElementById("xl2");
xl1.onchange = xl2.onchange = change;
showItem(xl2, xl1.selectedIndex === 1);
};
function change(e) {
var e = e || window.event;
if( this === xl1 ) {
var b = this.selectedIndex === 1;
showItem(xl2, b)
}
}
function showItem(el, b) {
el.style.visibility = b?"visible":"hidden";
}
})();
</script>
(function() {
var xl1,xl2
window.onload = function() {
xl1 = document.getElementById("xl1");
xl2 = document.getElementById("xl2");
xl1.onchange = xl2.onchange = change;
showItem(xl2, xl1.selectedIndex === 1);
};
function change(e) {
var e = e || window.event;
if( this === xl1 ) {
var b = this.selectedIndex === 1;
showItem(xl2, b)
}
}
function showItem(el, b) {
el.style.visibility = b?"visible":"hidden";
}
})();
</script>
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯