我有一個@ Html.DropDownList,它調用一個jquery函數。但它未能調用該函數。 我tried-MVC4視圖無法檢測JQuery
$(document).ready(function() {
$('.test').change(function() {
alert("1");
});
});
@Html.DropDownList("PropertyContent", ViewBag.PropertyList as List<SelectListItem>, new { @class="test"})
和
function test() {
alert("1");
}
@Html.DropDownList("PropertyContent", ViewBag.PropertyList as List<SelectListItem>, new { onchange="test();"})
@Scripts.Render("~/bundles/jqueryval") is also included in the view
請告訴我錯在這裏?
什麼是錯誤?你在控制檯中看到任何錯誤嗎?你在頁面中加入了「jQuery」嗎? – 2013-05-15 09:35:56
此外,您還必須編寫'$('。test')'而不是'$('test')'。因爲你想用'test'類訪問元素。 – 2013-05-15 09:37:05
@ Mojtaba-我已更新我的問題。其實我試過$('。test')。我沒有收到任何錯誤。它沒有調用該函數! – Sandy