材料设计使用jQuery禁用下拉列表

时间:2017-11-22 12:39:06

标签: jquery material-design

如何在使用dropdown点击按钮时停用材料设计jQuery

$("#btnoneway").click(function(){
  $(".airportToList").prop("disabled",true); 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="form-control airportToList"></select>

<a id="btnoneway">Click</a>

JS:

$.each(a.airports, function (key, value) {
            $(".airportFromList").append($('<option></option>').val(value.code).html(value.city +' , '+ value.country +'  ('+value.code+')' ));
            $(".airportToList").append($('<option></option>').val(value.code).html(value.city +' , '+ value.country +'  ('+value.code+')' ));
        });

        $('.airportFromList').change(function () {
            //alert($(this).val());
            //Code to select image based on selected car id
        });

        $('.airportToList').change(function () {
            //alert($(this).val());
            //Code to select image based on selected car id
        });

上面的jQuery无效。还有其他选择吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

在这里检查过,这个是工作gud。我给了“attr”而不是“prop”

$("#btnoneway").click(function(){
     $(".airportToList").attr("disabled","disabled"); 
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="form-control airportToList"> 
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<button id="btnoneway">click</button>