Ho un @ Html.DropDownList che chiama una funzione jquery. Ma non è riuscito a chiamare la funzione. devo tried-La vista MVC4 non rileva JQuery
$(document).ready(function() {
$('.test').change(function() {
alert("1");
});
});
@Html.DropDownList("PropertyContent", ViewBag.PropertyList as List<SelectListItem>, new { @class="test"})
e
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
Cosa c'è di sbagliato qui?
Qual è l'errore? Vedi qualche errore nella console? Includi 'jQuery' nella tua pagina? –
Inoltre devi scrivere '$ ('. Test')' invece di '$ ('test')'. Perché vuoi accedere agli elementi con la classe 'test'. –
@ Mojtaba- Ho aggiornato la mia domanda. In realtà ho provato con $ ('. Test'). Non ho alcun errore. Non sta invocando la funzione! – Sandy