 <p>You can change your markup to this </p> <pre><code>&lt;a class="like_counter_wrap fl_l"&gt; </code></pre> <p>now you wrap your function in a script tag and place it before the closing tag <code>body</code> (for performance)</p> <pre><code>&lt;script&gt; function openFullList(){ //do something } var button = document.querySelector(".like_counter_wrap");// document.querySelector("a"); button.addEventListener("click",openFullList,false); &lt;script&gt; </code></pre> <p>or put it in a file and bind it to your HTML like this </p> <pre><code>&lt;script src="script/myscript.js"&gt;&lt;/script&gt; </code></pre>