Javascript - Change button onclick to an existing function
<p>I have a button:</p>

<pre><code>&lt;button onclick = "doDisactivate(5);" id = "status_button_5" value = "Disactivate" /&gt;
</code></pre>

<p>where 5 is a dynamically added ID. I have two javascript functions, doDisactivate(ID) and doActivate(5). </p>

<pre><code>function doDisactivate(serviceID) {
    // logic that changes the button onclick to doActivate(serviceID)
}

function doActivate(serviceID) {
    // logic that changes the button onclick to doActivate(serviceID)
}
</code></pre>

<p>I'm guessing I can do the following with jquery:</p>

<pre><code>${"#status_button_" + serviceID}.click(function() {
    doActivate(serviceID);
});
</code></pre>

<p>But is there a way to directly assign the function while passing the ID as a parameter?</p>
