San*_*ndy 7 javascript jquery asp.net-mvc-4
我有一个@ Html.DropDownList,它调用一个jquery函数.但它未能调用该函数.我试过了-
$(document).ready(function () {
$('.test').change(function () {
alert("1");
});
});
@Html.DropDownList("PropertyContent", ViewBag.PropertyList as List<SelectListItem>, new { @class="test"})
Run Code Online (Sandbox Code Playgroud)
和
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
Run Code Online (Sandbox Code Playgroud)
这里有什么不对?
您的 jQuery 选择器是错误的,请改用 id-selector:
$(document).ready(function () {
$('#PropertyContent').change(function () {
alert("1");
});
});
Run Code Online (Sandbox Code Playgroud)
还有一些可能的错误:
$未知。可能的解决方案:
| 归档时间: |
|
| 查看次数: |
779 次 |
| 最近记录: |