简体   繁体   English

单选按钮更改事件jQuery

[英]RadioButton change event jquery

I write this event for RadioButton change event.but for first timer that page load.it doesnt work.why? 我为RadioButton更改事件编写此事件。但是对于第一次加载该页面的计时器。它不起作用。为什么?

//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) 如果您说的是页面加载时mapZoning的属性不变,那是因为您仅在DigitalFile中发生某些更改(即有人对其进行检查或取消选中)时才调用该函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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