Search code examples
jquerymarquee

Jquery Marquee Usage by Remy Sharp


I am using Remy Sharps Marquee Plugin. I am trying to figure out if it is possible to start/stop the marquee when a user presses a button. There is some demo code on the page, but that is within the plugin itself.

http://remysharp.com/2008/09/10/the-silky-smooth-marquee/

Thanks


Solution

  • Try assigning marque object to a global variable and then trigger start/stop on it.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="jquery.marquee.js" type="text/javascript"></script>
        <script>
        var marque;
        $(function () {
    
            marque= $('div.demo marquee').marquee('pointer');
        });
    
        function startmqr() {
            $(marque).trigger('start');
        }
        function stop() {
            $(marque).trigger('stop');
        }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div class="demo">
            <h2>
                Vanilla</h2>
            <pre><code>&lt;marquee behavior="scroll" scrollamount="1" direction="left" width="350"&gt;</code></pre>
            <marquee behavior="scroll" direction="left" scrollamount="2" width="350"><p>START Lorem ipsum dolor sit amet END</p></marquee>
        </div>
        <input id="Button1" type="button" value="start" onclick="startmqr()" />
        <input id="Button2" type="button" value="stop" onclick="stop()" />
        </form>
    </body>
    </html>
    

    Regards