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("")
            } 
});

 

posted @ 2019-04-09 09:39  quitpoison  阅读(4366)  评论(0编辑  收藏  举报