Trigger custom event
Description
The following code shows how to trigger custom event.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {<!-- www . j av a2s. c om-->
$("div").bind("myCustomEvent", function(e, myName, myValue) {
$(this).text(myName + ", hi there!");
});
$("button").click(function() {
$("div").trigger("myCustomEvent", [ "java2s.com" ]);
});
});
</script>
</head>
<body>
<div>java2s.com</div>
<button>bn</button>
</body>
</html>