我有一个 change() 事件未在 IE 11 中触发,但在 Chrome 和 Edge 中运行良好。任何帮助,将不胜感激
I have a change() event that's not firing in IE 11 but works fine with Chrome and Edge. Any help would be appreciated
<script>
// If the CountyId changes because the user selected a County from the DropDownList.
$(function () {
$("#RCE_CountyId").change(function () {
alert("It works !");
var countyId = $(this).val();
$("#RCE_RouteId").empty();
$("#RCE_RouteId").append("<option value=''>Select Route</option>");
//var d1 = '?handler=RouteList&CountyId=' + countyId;
//alert(d1);
$.getJSON('?handler=RouteList&CountyId=' + countyId, (data) => {
$.each(data, function (i, item) {
console.log("success");
$("#RCE_RouteId").append('<option value=' + item.routeId + '>' + item.routeName + '</option>');
});
});
});
});
</script>
您使用的 arrow function 不受 IE 支持。请将箭头函数替换为以下代码:
$.getJSON('?handler=RouteList&CountyId=' + countyId, function (data) {
...
});
<script>
// If the CountyId changes because the user selected a County from the DropDownList.
$(function () {
$("#RCE_CountyId").change(function () {
alert("It works !");
var countyId = $(this).val();
$("#RCE_RouteId").empty();
$("#RCE_RouteId").append("<option value=''>Select Route</option>");
//var d1 = '?handler=RouteList&CountyId=' + countyId;
//alert(d1);
$.getJSON('?handler=RouteList&CountyId=' + countyId, (data) => {
$.each(data, function (i, item) {
console.log("success");
$("#RCE_RouteId").append('<option value=' + item.routeId + '>' + item.routeName + '</option>');
});
});
});
});
</script>
您使用的 arrow function 不受 IE 支持。请将箭头函数替换为以下代码:
$.getJSON('?handler=RouteList&CountyId=' + countyId, function (data) {
...
});