 <p>You need to make the function doSomething like below, pass null for btn_b and pass value for btn_a. Hope this helps.</p> <p><strong>HTML</strong></p> <pre><code>&lt;input type="button" id="btn_a"&gt; &lt;input type="button" id="btn_b"&gt; </code></pre> <p><strong>SCRIPT</strong></p> <pre><code>$("#btn_a").on("click", function() { return doSomething(p,q,r); }); $("#btn_b").on("click", function() { return doSomething(p,q,null); }); function doSomething(p,q,r){ if(r != null){ //do something for btn_a and return } else { //do something for btn_b and return } } </code></pre>