使用jQuery提交表单后,保持当前选项卡

我正在尝试保留一个特定的选项卡(在本例中为tab2),但在单击提交按钮后,选项卡将恢复为具有认活动类的选项卡1.我用这个打了一堵砖墙.

这是我的例子[jsfiddle]

HTML:

    odo. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.

JavaScript的:

$(document).ready(function(){
    $('ul.tabs').each(function(){
        var $active,$content,$links = $(this).find('a');
        $active = $links.first().addClass('active');
        $content = $($active.attr('href'));
        $links.not(':first').each(function () {
            $($(this).attr('href')).hide();
        });

        $(this).on('click','a',function(e){
            $active.removeClass('active');
            $content.hide();
            $active = $(this);
            $content = $($(this).attr('href'));
            $active.addClass('active');
            $content.show();
            e.preventDefault();
        });
    });
});

CSS:

*         {padding:0; margin:0;}
html      {padding:15px 15px 0;font-family:sans-serif;font-size:14px;}
p,h3     {margin-bottom:15px;}
div       {padding:10px;width:600px;background:#fff;}
ul.tabs   {margin-left:2px;}
#tab1,#tab2 {border-top: solid 1px #ccc;margin-top: -1px; }
#tab2      {display:none;}a
ul.tabs li  {list-style:none;display:inline;}
ul.tabs li a   {padding:5px 10px;display:inline-block;background:#666;color:#fff;text-decoration:none;}
ul.tabs li a.active {background:#fff;color:#000;border: solid 1px #ccc; border-width: 1px 1px 0 1px;}

非常感谢您的帮助

最佳答案

Try this

dionIndex" runat="server" Value="0" />

将其放入编码中并按如下方式更改脚本

$("#accordion").accordion({
header: "h3",autoHeight: false,event: "mousedown",active: activeIndex,ui: "PageName.aspx",change: function (event,ui) {
var index = $(this).accordion("option","active");
$('#<% =hidAccordionIndex.ClientID %>').val(index);
}
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...