js 动态加载select触发事件
动态加载select后,手动调用一下 subjectChange函数,模拟触发change事件
function hallidChange(value) { $.ajax({ type: "post", url: "/Common/GetSessions", data: { hallId: value, dateTime: $("#currentTime").val(), timeinterval: $("#timeinterval").val() }, success: function (str) { console.log(str); var obj = str; if (obj.code == "200") { $("#sessionId").empty(); for (var key in obj.result) { $("#sessionId").append("<option value = " + key + " > " + obj.result[key] + "</option > "); } subjectChange($("#sessionId").val()); } else { layer.msg(obj.message, { icon: 7, time: 1500 }); } }, error: function () { layer.msg('发生错误,请联系客服!', { icon: 2, time: 1500 }); } }); }