Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript event listener when registred 2nd time doesn't work
    text
    copied!<p>i have two js function as given below the function nexPage is working fine but the previousPage function when called the event webkitAnimationEnd doesnt works as desired . link to jsfiddle:<a href="http://jsfiddle.net/K8Tuy/24/" rel="nofollow">link to jsfiddle</a></p> <pre><code>var currentPage = 0; function nextPage() { alert(currentPage); var pages = document.getElementsByClassName('pages'); pages[currentPage].className = "pages pageanim"; pages[currentPage].addEventListener('webkitAnimationEnd', function(){ this.style.left = '0%'; this.style.zIndex = currentPage; currentPage = currentPage+1; }, false); } function previousPage() { //alert(currentPage); var pages = document.getElementsByClassName('pages pageanim'); pages[0].className = "pages revpageanim"; pages[0].addEventListener('webkitAnimationEnd', function(){ this.style.left = '49%'; this.style.zIndex = currentPage+1; currentPage = currentPage-1; }, false); } </code></pre> <p>here is my html </p> <pre><code> &lt;body onLoad="applyZindex();"&gt; &lt;!-- Add your site or application content here --&gt; &lt;header&gt;&lt;button class="nav left" onClick="previousPage();"&gt;&amp;lt;&amp;lt;prev&lt;/button&gt; &lt;h3 class="left"&gt;Previewer (TM) &lt;/h3&gt;&lt;button class="nav right" onClick="nextPage();"&gt; next&gt;&gt;&lt;/button&gt;&lt;/header&gt; &lt;section style=" position:relative;"&gt; &lt;img src="img/1.jpg" alt="page1" title="page1" class="pages" /&gt; &lt;img src="img/2.jpg" alt="page2" title="page2" class="pages" /&gt; &lt;img src="img/3.jpg" alt="page1" title="page1" class="pages" /&gt; &lt;img src="img/4.jpg" alt="page2" title="page2" class="pages" /&gt; &lt;/section&gt; &lt;footer&gt;&lt;/footer&gt; &lt;/body&gt; </code></pre>
 

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