开发者

jquery to set dotnet form visible=true and false

开发者 https://www.devze.com 2023-04-10 13:02 出处:网络
I have a tabbed login page, that I would like to host a single form on each tab, but from the code behind they are on a single page.

I have a tabbed login page, that I would like to host a single form on each tab, but from the code behind they are on a single page.

This means there are two forms.

example:

<nav id="secondary">
<ul>
<li id="current"><a href="#login">Login</a></li>
<li><a href="#forgot">Forgot Password</a></li>
</ul>
</nav>


<div id="login" class="tab">
<br /><br />
<form runat="server" visible="true" class="frmControl">
</form>
</div>
<div id="forgot" class="tab">
<br /><br />
<form runat="server" visible="false" class="frmControl"></form>
</div>

and then I have the following jquery to toggle between the login div and forgot div

$(".tab").hide();

if ($("nav#secondar开发者_运维知识库y ul li.current").length < 1) {
    $("nav#secondary ul li:first-child").addClass("current");
}

var link = $("nav#secondary ul li.current a").attr("href");
$(link).show();

$("nav#secondary ul li a").click(function () {
    if (!$(this).hasClass("current")) {
        $("nav#secondary ul li").removeClass("current");
        $(this).parent().addClass("current");
        $(".tab").hide();
        $(".frmControl").attr("Visible", "false");
        var link = $(this).attr("href");
        $(this).attr("Visible", "true");
        $(link).show();
        initBackground();
    }
    return false;
});

It is not working correctly, as it is only setting the '.frmControl' class to visible=false. but when i reactivate the tab, it does not set this to true again for the active tab form and set the inactive tab form to false.

sorry if I am not explaining this correctly.

-RD


you do not want to set $(".frmControl").attr("Visible", "false"); because you already hiding the tab using $(".tab").hide();

$(".tab").hide();

if ($("nav#secondary ul li.current").length < 1) {
    $("nav#secondary ul li:first-child").addClass("current");
}

var link = $("nav#secondary ul li.current a").attr("href");
$(link).show();

$("nav#secondary ul li a").click(function () {
    if (!$(this).hasClass("current")) {
        $("nav#secondary ul li").removeClass("current");
        $(this).parent().addClass("current");
        $(".tab").hide();
      //  $(".frmControl").attr("Visible", "false");// remove this line
        var link = $(this).attr("href");
        $(this).attr("Visible", "true");
        $(link).show();
        initBackground();
    }
    return false;
});

Here is working example http://jsfiddle.net/VGRZS/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号