简体   繁体   中英

jquery on change does not work in asp net mvc

Can someone explain me why this code below does not hit the on change function?

HTML

<div class="form-group">
    @Html.DropDownList("Relatorios", ViewBag.Tipos as SelectList, new { id = "Relatorios"})
</div>

Script

$(document).ready(function () {

    $("#Relatorios").on("change", function () {
        alert("Success");
    });
}); 

I expected that function to hit when I change de option in the drop down list

I resolved the problem with the code below

$(window).load(function () {
        $("#Relatorios").on("change", function () {
            settabledata();
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM