Note that there are some explanatory texts on larger screens.

plurals
  1. POLife Counter Issue
    text
    copied!<p>I was builiding lately life counter and i can't figure out what the issue around here, I mean i got 2 divs, when you on div with class "alive" you get score up and when you in "dead" div you get score down.</p> <p>Now I've made this code that work on seconds, but it not working stright, I mean 1, 2, 3. But it working like this: <a href="http://jsfiddle.net/4Tby5/" rel="nofollow">http://jsfiddle.net/4Tby5/</a></p> <p>Or as visual code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;Alive - Dead&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt; &lt;script&gt; var l = 1; var good = " Excelent!"; var bad = " OH NO!"; $(document).ready(function () { $('#alive').hover(function () { if (l &gt; 100) { window.clearTimeout("tim"); } else { document.getElementById("percent").innerHTML = "Life: " + l + good; l++; var tim = window.setTimeout("count()", 1000); } count(); }); }); $(document).ready(function () { $('#dead').hover(function () { if (l &lt; 0) { window.clearTimeout("tim"); } else { document.getElementById("percent").innerHTML = "Life: " + l + bad; l--; var tim = window.setTimeout("count()", 1000); } count(); }); }); &lt;/script&gt; &lt;style&gt; body { background: red; } .dead { cursor: url(thumb-down.cur) 6 6, auto; padding-bottom: 285px; } .alive { background: #32ff0a; height: 300px; margin: -8px; cursor: url(thumb-up.cur) 6 6, auto; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="alive" id="alive"&gt; Stay here to survive! &lt;/div&gt; &lt;div class="dead" id="dead"&gt; &lt;br /&gt; Stay away from dead area! &lt;/div&gt; &lt;div id="percent"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>So my question is how can i fix this to get it 1,2,3 (replace 1 with 2 and 3, 4...)?</p>
 

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