取消确认后,下拉列表选择默认值

时间:2017-09-13 07:28:59

标签: javascript jquery drop-down-menu

example 我的下拉列表加载了这个:     @ Html.EnumDropDownListFor(x => x.field,new {@class =“form-control select”,type =“text”,id =“dropdownlist”})

Javascript:
$("#dropdownlist").on("change",function () {
            var asdf= document.getElementById("#dropdownlist");
            swal({...},function (isConfirm) {
                  if (isConfirm) {
//post url
}
else{
if isconfirm false I want to dropdown list selected default value
how ı can
}

1 个答案:

答案 0 :(得分:0)

你走了:

    $("#dropdownlist").on("change",function () {
            var asdf= document.getElementById("#dropdownlist");
            swal({...},function (isConfirm) {
                  if (isConfirm) {
    //post url
    }
    else{
        $("#dropdownlist option:first").attr('selected','selected');  //this will do the job for you.
    }
相关问题