javascript - 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);
}
});
});
解决方案
推荐阅读
- python - 为 pandas 数据框中的所有列提取显式类型
- javascript - 砌体布局问题
- sonarqube - 缺少 SonarQube 已弃用的规则建议
- python - 我可以使用 Python 为 Influxdb 中的某个点设置特定时间吗?
- bash - 在 Bash /bin/kill 中找不到执行
- xcode - Xcode 10 打破了 Ionic Cordova 构建
- python - 如何在 Redhat Linux 上安装 pip
- android - @UnsupportedAppUsage 注释描述了什么
- ios - moya 中的多部分表单数据,在 swift 中具有 int 值
- android - Android Things 中的锁屏