使用jQuery与单选按钮隐藏/显示表行 [英] Using JQuery with RadioButtons to hide/show table rows

查看:109
本文介绍了使用jQuery与单选按钮隐藏/显示表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的MVC形式两个单选按钮,我用它来隐藏或在表中显示的行。

它工作正常在Firefox,而不是IE浏览器。看来,在IE浏览器的jQuery函数只被当我选择第一个单选按钮激发。我添加了额外的单选按钮,以确认它仅触发第一个。

要使我的按钮:
        
            <%= Html.RadioButton(频率,人民日报)%>
            日常
        


        
            <%= Html.RadioButton(频率,周末画报)%>
            每周
        

我的功能是:

  $('#表输入ScheduleTable频率#')addClass(FrequencyOption);
$('。FrequencyOption')。改变(函数(){
    如果($(本).attr('检查')==真&放大器; $(本).VAL()==人民日报){
        $('recurEveryBox。')儿童()显示()。
        $('。weekDayOption')儿童()隐藏()。
    };
    如果($(本).attr('检查')==真&放大器; $(本).VAL()==周刊){
        $('recurEveryBox。')儿童()显示()。
        $('。weekDayOption')儿童()显示()。
    }
});


解决方案

我们已经运行了jQuery code之前检查对象的长度。不知道这是否是做确切的最好方式......但它的工作原理,我们已经花了足够的时间! ;)

Thansk所有帮助。

I have two radio buttons on my MVC form that I use to hide or show a row in a table.

It works fine in firefox, but not IE. It seems that in IE the JQuery function is only being fired when i select the first radio button. i have added extra radio buttons to confirm that it only fires on the first.

To render my buttons: <%= Html.RadioButton("Frequency", "Daily") %> Daily

and <%= Html.RadioButton("Frequency", "Weekly")%> Weekly

My function is:

$('table#ScheduleTable input#Frequency').addClass("FrequencyOption");
$('.FrequencyOption').change(function() {
    if ($(this).attr('checked') == true & $(this).val() == "Daily") {
        $('.recurEveryBox').children().show();
        $('.weekDayOption').children().hide();
    };
    if ($(this).attr('checked') == true & $(this).val() == "Weekly") {
        $('.recurEveryBox').children().show();
        $('.weekDayOption').children().show();
    }
});

解决方案

We had to check the length of the object before running the jQuery code. Don't know if this was the exact best way to do it... but it works and we've spent enough time! ;)

Thansk for all the help.

这篇关于使用jQuery与单选按钮隐藏/显示表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆