简体   繁体   中英

RadioButton change event jquery

I write this event for RadioButton change event.but for first timer that page load.it doesnt work.why?

//html mvc code
    @Html.RadioButtonFor(m => m.DigitalFile, false) خیر
    @Html.RadioButtonFor(m => m.DigitalFile, true) بله

     <script>
    $(function () {
        $("input[name='DigitalFile']").change(function () {
        var $this = $(this);
        if ($this.val() == "True") {
            $("#MapZoning").attr("disabled", false);
        } else {
            $("#MapZoning").attr("disabled", true);
        }
        });
    });
</script>

I didn't get your question. .but for first timer that page load.it doesnt work.why? If you are saying that when the page loads, the attribute of mapZoning doesn't change, then that's because you are only calling the function when some change occurs in your DigitalFile (ie, someone, checks it or unchecks it)

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