开发者

jQuery accordion can't disable click when still animating?

I've attempting to develop a jQuery accordion, which is work ing pretty well so far cons开发者_运维百科idering I don't really know jQuery.

The main problem i have is if you click about quite quickly on different sections it will eventially knock the whole accordion out for a short time which wouldn't be good enough really.

I attempted to put

if ($("#accordion ul li").is(':animated')) {

around the click function but didn't seem to do anything, could anyone give me a helping hand or tell me if it is at least possible?

Also you will notice that when clicked on, the right side of the accordion shrinks a little, is this fixable or just something i'll have to put up with?

You can view what i mean here http://dev.boomeranginternet.co.uk/accordion/accordion1.asp

Thanks in advance for any help.

Regards, J.


Try something like this insted:

$("#accordion ul li").click(function(){
    if ($(':animated').length) {
        return false;
    }

    //Your code goes here...
});


by putting around the click function you mean like this?

    if ($("#accordion ul li").is(":animated")) { 

    } else {
        $("#accordion ul li").click(function() {
            // do animation
        }):
    }

thats the wrong way around, the click function defines an event handler. if you want your animation to only run as long as no other animation is running you must check inside your event handler e.g.

$("#accordion ul li").click(function() {
    if ($("#accordion ul li").is(":not(animated)")) { 
        // do animation
    }
}):
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜