@Html.DropDownList("city",(SelectListItem)ViewBag.city,new { @class = "form-control", @onchange="fun1()"})
$(document).ready(function fun1() {
alert("Selected item value is " + $("#city").val() + " and Selected item
text is " + $("#city option:selected").text());
});
答案 0 :(得分:0)
在document.ready之外写下你的函数function fun1()
。它会起作用。