 <p>the variable countn should be accessable from both functions. i put everything in an anonymous function, so only both click event handler can access the variable.</p> <pre><code>(function () { var countn=0; $('#gallery').on('click', '.gon', function() { // increment countn }); $('.teaserbox').click(function() { // reset countn }); })(); </code></pre>