使用html下拉列表显示none和block

时间:2014-08-20 14:24:54

标签: javascript jquery html css drop-down-menu

使用JavaScript

显示无和使用html下拉列表进行阻止
function getval(sel) {
    if (document.getElementById("applicant").value = "2") {
        document.getElementById('li2').style.display = 'block';
        document.getElementById('li3').style.display = 'none';
        document.getElementById('li4').style.display = 'none';
        document.getElementById('li5').style.display = 'none';
    }
    else if (document.getElementById("applicant").value = "3") {
        document.getElementById('li2').style.display = 'block';
        document.getElementById('li3').style.display = 'block';
        document.getElementById('li4').style.display = 'none';
        document.getElementById('li5').style.display = 'none';
    }
    else if (document.getElementById("applicant").value = "4") {
        document.getElementById('li2').style.display = 'block';
        document.getElementById('li3').style.display = 'block';
        document.getElementById('li4').style.display = 'block';
        document.getElementById('li5').style.display = 'none';
    }
    else if (document.getElementById("applicant").value = "5") {
        document.getElementById('li2').style.display = 'block';
        document.getElementById('li3').style.display = 'block';
        document.getElementById('li4').style.display = 'block';
        document.getElementById('li5').style.display = 'block';
    }
}

1 个答案:

答案 0 :(得分:1)

在不知道问题是什么的情况下(因为你不能描述它),我猜测它(你错过了=)。

更改

if (document.getElementById("applicant").value = "..."

if (document.getElementById("applicant").value == "..."