jquery和js 判断下拉框选项选中值

js

<script>
    var selectId = document.getElementById("VariantType");//获取ID
    selectId.onchange = function ()
    {
        var result = selectId.options[selectId.selectedIndex].innerHTML;//获取选中文本
        if (result == "Fusion") {  //当变异类型的值为Fusion时,变异值为空
            $("#Variant").val("");
        }
    }
</script>

jquery

$("#VariantType").change(function () {
            var result = $(this).children('option:selected').val();
            if (result  == "Fusion") {
                $("#Variant").val("")
            } 
});

猜你喜欢

转载自www.cnblogs.com/quitpoison/p/10674975.html