I have a @Html.DropDownList which calls a jquery function. But it failed to call the function. I have tried-
$(document).ready(function () {
$('.test').change(function () {
alert("1");
});
});
@Html.DropDownList("PropertyContent", ViewBag.PropertyList as List<SelectListItem>, new { @class="test"})
and
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
Whats wrong here?
jQueryin your page?$('.test')instead of$('test'). Because you want to access elements withtestclass.