Prev Demo
jQuery
>
.Bind() .Unbind() - Attach & Detach Event
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> </head> <body> <form> <input type="button" id="btnAction" value="Constatnt" style="color:blue;background-color:yellow"/> <input type="button" name="btn" id="btnBindAction" value="Bind"/> <input type="button" name="btn" id="btnUnbindAction" value="UnBind"/> </form> <script> function bindAction() { alert("I am active !"); } $("#btnBindAction").click(function () { $("#btnAction").bind('click', bindAction).val("Click Now"); }); $("#btnUnbindAction").click(function () { $("#btnAction").unbind('click', bindAction).val("Simple Button"); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output