I have the following jQuery code :
$("#btnReset").click(function () {
ColReorder.fnReset(oTable);
return false;
});
And the HTML as follows :
<div style="padding: 5px 5px 1px 0px; float: right" id="globalbutton-row" class="ex">
<button class="button" type="button" id="btnReset"><%=rb.getString("button.reset")%></button>
<button class="button" type="button" id="btnDeveloperSampleMenu" onclick="javascript:CallDeveloperSampleMenu()"><%=rb.getString("button.devsamplemenu")%></button>
</div>
I want the button ‘Reset’ to launch the function ColReOrder.fnReset but for some reason this does not work.
try using event delegation. Chances are the element hasn’t loaded into the dom when your javascript is getting executed. attaching the click event to the document will make the code work by listening to click and then searching for your selector at the time of the click.