jquery bind click event
-
24-10-2019 - |
Question
I am having a problem with my code
if (text.length < 1)
{ args.IsValid = false; $('#<% = cmdSaveRequest.ClientID()> %>').removeAttr('click'()); } else { $('#<% = cmdSaveRequest.ClientID()> %>').click(savingData()); args.IsValid = true; }
when I assign click event like
$('#<% = cmdSaveRequest.ClientID() %>').click(savingData());
it executes the saving data function Is there any way to bind the click event to button but whiteout executing the function just bind it and after user clicks the button then the function executes?
Solution
Try
$('#<% = cmdSaveRequest.ClientID() %>').click(savingData);
No paranthesis by savingData
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow