首页 > 解决方案 > select2 v4 下拉更改事件不起作用

问题描述

请帮助我,select2 v4+ 更改事件不起作用。这是我的代码:

$(document).ready(function(){
  $("#asal").on("change", function(){
  var asallbl = $("#asal :selected").parent().attr("label");
  if(asallbl === "Singapore"){
    $("#tujuan").find("optgroup[label='Indonesia']").show();
    $("#tujuan").find("optgroup[label='Singapore']").hide();
    $("#tujuan").prop("selectedIndex", 0);
  }else{
    $("#tujuan").find("optgroup[label='Indonesia']").hide();
    $("#tujuan").find("optgroup[label='Singapore']").show();
    $("#tujuan").prop("selectedIndex", 0);
  }
  });
});

标签: javascriptjqueryjquery-select2

解决方案


推荐阅读