jQuery的.show()不工作的ASP MVC 3字段集 [英] jquery .show() not working on ASP MVC 3 fieldsets

查看:175
本文介绍了jQuery的.show()不工作的ASP MVC 3字段集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我使用周期的jQuery通过一组字段集元素,并从一组单选按钮,根据用户的选择,决定哪个应该可见,哪些应该被隐藏(它们都隐藏在页面加载时)。但是,我不能让 .show()的方法来工作。

Below is the jquery I'm using to cycle through a group of fieldset elements and, based upon the user's selection from a group of radio buttons, decide which one should be visible and which should be hidden (they are all hidden when the page loads). However, I can't get the .show() method to work.

的jQuery

$(document).ready(function () {
    $('input[name=TransactionType]').change(function () {
        var radioValue = $(this);
        var elements = [];

        $('#RightDiv').children().each(function () {
            console.log(radioValue.attr('id') + " " + $(this).attr('id'));
            if (radioValue.attr('id') == $(this).attr('id')) {
                console.log('here');
                $(this).show();
            } else {
                $(this).hide();
            }
        });
    });
});

ASP MVC

<div id="LeftDiv" style="width:450px;float:left;">
    <fieldset style="width:350px;">
        @Html.RadioButton("TransactionType", false, new { @id = "Enroll" }) Enroll a Tax ID for EFT <br />
        @Html.RadioButton("TransactionType", false, new { @id = "New" }) New Tax ID Without EFT Enrollment <br />
        @Html.RadioButton("TransactionType", false, new { @id = "ModT" }) Modify EFT Information by Tax ID <br />
        @Html.RadioButton("TransactionType", false, new { @id = "ModA" }) Modify EFT Information by Agent ID <br />
        @Html.RadioButton("TransactionType", false, new { @id = "Clone" }) Clone EFT on to a Sub Agent ID <br />
        @Html.RadioButton("TransactionType", false, new { @id = "Unenroll" }) Unenroll EFT by Tax ID 
    </fieldset>        
</div
<div id="RightDiv" style="width:420px;float:left;">
    <fieldset id="Enroll" style="width:350px; visibility: hidden;">...</fieldset> 
    <fieldset id="New" style="width:350px; visibility: hidden;">...</fieldset>   
    <fieldset id="ModT" style="width:350px; visibility: hidden;">...</fieldset>
    <fieldset id="Clone" style="width:350px; visibility: hidden;">...</fieldset> 
    <fieldset id="Unenroll" style="width:350px; visibility: hidden;">...</fieldset>                 
</div>

下面是从jQuery环控制台读取的屏幕截图

Here's a screen shot of the console readout from the jquery loop

推荐答案

更改可见性:隐藏; 您的fieldsets到显示:无;

Change the visibility: hidden; of your fieldsets to display: none;.

这将解决您的问题。

这篇关于jQuery的.show()不工作的ASP MVC 3字段集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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