开发者

jQuery - remove function attached to div

开发者 https://www.devze.com 2023-01-07 22:57 出处:网络
I\'m running into a problem with jQuery, so I think I\'ve figured out a workaround, but need help. I currently attach a cycle() slideshow to my div like this:

I'm running into a problem with jQuery, so I think I've figured out a workaround, but need help.

I currently attach a cycle() slideshow to my div like this:

function startSlideshow() {
    $('#slideshow').cycle({ some parameters });
}

When I pause and restart this slideshow, it exhibits weird behavior, due to bugs in the cycle plugin. So my workaround idea is this: to destroy the existing cycle() a开发者_开发技巧nd then just recreate it on the fly.

I can easily recreate it by calling startSlideshow() again... but how do I kill the old cycle() that's attached to the div?

I guess I'm looking for a way to "unset" or "unbind" it completely (and jQuery's unbind() method isn't it).

Thanks-- Eric


Use the the plugins destroy command, it has been added to version 2.80

$('#slideshow').cycle('destroy');


You can use $('#slideshow').cycle('destroy');

But are you sure the weird behaviour is due to the cycle plug-in having bugs ? and not improper usage of it ?

How do you pause and restart the cycling ?


First you remove the attached cycle command. Then you remove the inline styles created by cycle:

$("#slideshow").cycle("destroy");
$("#slideshow, #slideshow *").removeAttr("style");
startSlideshow(); // recreate cycle slideshow
0

精彩评论

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