Prev Demo
jQuery
>
Attach Custom Event To Element
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> <div id="divCustom" style="border: 1px solid #c0c0c0; padding: 5px; padding: 10px;"> DotNetFunda.com | ItFunda.com </div> <input type="button" id="btnCustomEvent" value="Trigger Custom Event" /> <div id="divDemo" style="font-size: 50px;">Demo Text</div> <script type="text/javascript"> function MyFunction() { $("#divDemo").slideUp().delay("500").slideDown(); } $("#divCustom").bind("myCustomEvent", MyFunction); $("#btnCustomEvent").click(function () { $("#divCustom").trigger("myCustomEvent"); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output