JQuery - 关闭所有标签,停止手风琴链接

时间:2012-09-09 16:14:20

标签: javascript jquery

我希望有人能帮助我解决我使用JQuery Accordion插件的问题。我对JQuery的经验很少,所以非常感谢任何帮助!

基本上,我在我的一个手风琴标签内有一个链接,它会加载一个新窗口。但是,当发生这种情况时,它会关闭父窗口中的所有手风琴链接。我认为这样做是因为它将链接视为我不想要的手风琴的一部分。

以下是javascript代码:

<script type="text/javascript" src="js/accordion/chili-1.7.pack.js"></script>
<script type="text/javascript" src="js/accordion/jquery.easing.js"></script>
<script type="text/javascript" src="js/accordion/jquery.dimensions.js"></script>
<script type="text/javascript" src="js/accordion/jquery.accordion.js"></script>
<script type="text/javascript">
    jQuery().ready(function(){
        // simple accordion
        /*jQuery('#accordion').accordion();*/
        jQuery('#accordion_click').accordion({
            /*animated: 'bounceslide'*/
            animated: 'easeslide',
            autoheight: true

        });

        jQuery('#accordion_hover').accordion({
            /*animated: 'bounceslide'*/
            event: 'mouseover',
            animated: 'bounceslide',
            autoheight: true

        });
    });
</script>

这是我的HTML代码:

<a>Accordion Tab 1</a>
<div>
<a href="#" class="basic nonaccordion" onClick="MyWindow=window.open('www.newwindow.com','New_Window','toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=yes,width=400,height=200'); return false;">Load Window </a>
</div>

<a>Accordion Tab 2</a>
<div>
</div>

<a>Accordion Tab 3</a>
<div>
</div>

<a>Accordion Tab 4</a>
<div>   
</div>

我是否可以轻松地从手风琴中删除标签1中的链接,以便在新窗口加载时不会关闭标签?

谢谢!

编辑:CSS的内容如下:

/*tab, accordion*/
/*tab 1*/
ul.tabs { margin: 0; padding: 0; float: left; list-style: none; height: 32px; border-bottom: 1px solid #c8c8c8; border-left: 1px solid #c8c8c8; width: 100%; }
ul.tabs li { float: left; margin: 0; padding: 0; height: 31px; line-height: 31px; border: 1px solid #c8c8c8;    border-left: none; margin-bottom: -1px; overflow: hidden; position: relative; background: #f5f5f5; }
ul.tabs li a { text-decoration: none; color: #9b9b9b; display: block; font-size:12px; font-family:Georgia, "Times New Roman", Times, serif; letter-spacing:3px; text-transform:uppercase; padding: 0 20px; border: 1px solid #fff; outline: none;}
ul.tabs li a:hover, ul.tabs li.active a { background: #fff; color:#000; }
html ul.tabs li.active, html ul.tabs li.active a:hover  { background: #fff; border-bottom: 1px solid #fff; }
.tab_container { border: 1px solid #f5f5f5; border-top: none; overflow: hidden; clear: both; float: left; width: 100%; background: #fff; margin:0 0 20px 0; }
.tab_content { padding: 20px; }

/*tab 2*/
ul.tabs2 { margin: 0; padding: 0; float: left; list-style: none; height: 32px; border-bottom: 1px solid #c8c8c8; width: 100%; }
ul.tabs2 li { float: left; margin: 0; padding: 0; height: 31px; line-height: 31px;  border-left: none; margin-bottom: -1px; overflow: hidden; position: relative; }
ul.tabs2 li a { text-decoration: none; color: #9b9b9b; display: block; font-size:12px; font-family:Georgia, "Times New Roman", Times, serif; letter-spacing:3px; text-transform:uppercase; padding: 0 20px; border: 1px solid #fff; outline: none;}
ul.tabs2 li a:hover, ul.tabs2 li.active a { background: #fff; color:#000; }
html ul.tabs2 li.active { background: #fff; border-top: 1px solid #c8c8c8; border-left: 1px solid #c8c8c8; border-right: 1px solid #c8c8c8;border-bottom: 1px solid #fff; }
html ul.tabs2 li.active a:hover{ color:#000; } 
.tab2_container { border: 1px solid #f5f5f5; border-top: none; overflow: hidden; clear: both; float: left; width: 100%; background: #fff; margin:0 0 20px 0; }
.tab2_content { padding: 20px; }

/*accordion*/
.basic  { width:100%; margin-bottom:40px;  }
.basic div {  background:none; }
.basic p { margin-bottom : 0px; border: none; text-decoration: none; padding: 10px;}
.basic a { cursor:pointer; display:block; padding:10px 10px; margin-top: 0; text-decoration: none; color: black; border: 1px solid #e3e3e3; font-size:12px; font-family:Georgia, "Times New Roman", Times, serif; letter-spacing:3px; text-transform:uppercase; color: #9b9b9b;  background: #f5f5f5 url(../images/collapsed.png) no-repeat 99% 50%; margin-bottom:1px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;}
.basic a:hover { background-color:#fafafa; }
.basic a.selected { color: black; background: #fafafa url(../images/expanded.png) no-repeat 99% 50%;}

1 个答案:

答案 0 :(得分:0)

您发布的CSS似乎与HTML + JS无关。

尝试使用header选项,并在手风琴元素> a之后直接指定标题:http://jsfiddle.net/AkX3z/

我包含了jQuery UI演示提供的$.accordion的基本演示。它没有这个问题,这意味着它可能是由于您排除了正确的标题。