Bind unbind event in jQuery

By
Advertisement
Introduction:
In my previous article I have explained about  How to get current url using javascript,jquery and C#Net. In this article I am going to explain about how to bind and unbind events in jQuery.

Explanation:
In the form I have a button with id “btnsubmit”. Below is the code.

<input id="btnsubmit" type="button" value="Submit" />

My requirement is I need to bind a function to the onclick event  of the button and unbind it whenever it is not necessary. To achieve this first define the function like the below.

var testingfn=function() {
//your code here
};


To bind the click event to the button(btnsubmit) below code is used

$('#btnsubmit').click(testingfn);
           
To unbind the click event to the button(btnsubmit ) below code is used

$('#btnsubmit').unbind("click");

Do you like this article? Help us to improve. Please post your comments below.

0 comments:

Post a Comment

Online Casino