Search code examples
jqueryscroller

How to Stop li-scroller?


I am using this plugin: Li-Scroller Here is the Code: Jquery Function Code

I there any way I can destroy/stop/restart it (remove all divs and mark up and then start it again) when it is applied to an unordered list via a function.

<ul id="ticker01">
    <li><span>10/10/2007</span><a href="#">The first thing ...</a></li>
    <li><span>10/10/2007</span><a href="#">End up doing is ...</a></li>
    <li><span>10/10/2007</span><a href="#">The code that you ...</a></li>
    <!-- eccetera -->
</ul>
$("ul#ticker01").liScroll();

JSFiddle


Solution

  • To stop and destroy the scroller you just need to "undo" everything the li-scroller adds so you can use the followiing jQuery:

    $("ul#ticker01")
        .clearQueue().stop()       //stops animation
        .unwrap()                  //removes mask div
        .unwrap()                  //removes tickercontainer div
        .unbind()                  //unbinds any events attached (like hover)
        .removeClass('newsticker') //removes the extra class
        .removeAttr('style');      //removes the height style
    

    Example