Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - Need help stopping animation on click command
    primarykey
    data
    text
    <p>With a few of your help I was able to get the jquery I wanted to work flawlessly, except for one thing.. the animation doesn't stop when i click on the buttons.</p> <p><strong>Scenario:</strong><br> I have an Image, and 3 buttons underneath labeled "1","2", and "3". The jquery will automate the click function every 4500ms and switch from 1 to 2, then 2 to 3 and continuously loop. However the problem is, if I manually click on a 1,2,3 button the animation does not stop.</p> <p>Any ideas how I could accomplish this?</p> <p><strong>jQuery:</strong></p> <pre><code>var tabs; var len; var index = 1; var robot; function automate() { tabs.eq((index%len)).trigger('click'); index++; } robot = setInterval(automate, 5500); jQuery(document).ready(function(){ jQuery(".imgs").hide(); jQuery(".img_selection a").click(function(){ stringref = this.href.split('#')[1]; $(".img_selection a[id$=_on]").removeAttr('id'); this.id = this.className + "_on"; jQuery('.imgs').hide(); if (jQuery.browser.msie &amp;&amp; jQuery.browser.version.substr(0,3) == "6.0") { jQuery('.imgs#' + stringref).show(); } else jQuery('.imgs#' + stringref).fadeIn(); return false; }); $('.img_selection a').removeAttr('id').eq(0).trigger('click'); tabs = jQuery(".img_selection a"); len = tabs.size(); }); </code></pre> <p>I tried adding the below code, with a lot of help from this website, but to no avail..</p> <p><strong>CODE:</strong></p> <pre><code>jQuery(document).ready(function(){ jQuery(".imgs").hide().click(function(){ clearInterval(robot); }); </code></pre> <p><strong>HTML:</strong></p> <pre><code>&lt;!-- TOP IMAGE ROTATION --&gt; &lt;div id="upper_image"&gt; &lt;div id="img1" class="imgs"&gt; &lt;p&gt;&lt;img src="images/top_image.jpg" width="900" height="250" alt="" border="0" /&gt;&lt;/p&gt; &lt;/div&gt; &lt;div id="img2" class="imgs"&gt; &lt;p&gt;&lt;img src="images/top_image2.jpg" width="900" height="250" alt="" border="0" /&gt;&lt;/p&gt; &lt;/div&gt; &lt;div id="img3" class="imgs"&gt; &lt;p&gt;&lt;img src="images/top_image3.jpg" width="900" height="250" alt="" border="0" /&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- / TOP IMAGE ROTATION --&gt; &lt;!-- TOP IMAGE SELECTION --&gt; &lt;ul class="img_selection"&gt; &lt;li&gt;&lt;a id="img1_on" class="img1" href="#img1"&gt;1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="img2" href="#img2"&gt;2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="img3" href="#img3"&gt;3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;!-- / TOP IMAGE SELECTION --&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload