English 中文(简体)
议题 简历
原标题:issue with accordian Jquery script

我写了在流动网站上部署的礼让文字,每件工作都是罚款的。 然而,当页数增加时,我面临一个问题。

约有8至10条条条条条条。 当一把任何物品的碎块 down倒和点击以显示内容时,页数正转向顶,而不是停留在我点击的目前位置。

请向我建议解决办法。

说明如下:

$( .acc_container ).hide(); $( .acc_container1 ).hide();

$( .acc_trigger ).click(function(){ $(this).siblings( .acc_container1 ).slideUp( fast ); $(this).parent().siblings( div ).children( .acc_container1 ).slideUp( fast ); $(this).parent().siblings( div ).children( .acc_container ).slideUp( fast ); $(this).next().siblings( .acc_container ).slideDown( fast ); });

最佳回答

On each of your accordion s triggers which display content, which I assume are anchor tags, you need to prevent the default behavior of the event. Which in the case of anchor tags, is to take you too the href attribute of the tag. If the href attribute is set to #, clicking on the anchor tag will take you to the top of the page. So, something like this should work, calling preventDefault() on jQuery s event object, assuming .acc_trigger is the selector for all of your accordian triggers:

$(".acc_trigger").click(function(e) {
    $(this).siblings( .acc_container1 ).slideUp( fast );
    $(this).parent().siblings( div ).children( .acc_container1 ).slideUp( fast );
    $(this).parent().siblings( div ).children( .acc_container ).slideUp( fast );
    $(this).next().siblings( .acc_container ).slideDown( fast );
    e.preventDefault();
});
问题回答

假设你点击的话,我会点击。

$("a").click(function(event) {
// do all your logic here and add the below link  

event.preventDefault();

});

如果没有

您.acc_container 页: 1

height:600px;
overflow: hidden;

这应当谨慎行事。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签