MENU
Generic Event Manipulator
.bind(...) .unbind(...) .delegate(...) .undelegate(...)(Superseded by .on() and .off().).on(String eventTypes [,String selector][, Any data], function(Event e) handler).on(Object events [,String selector][, Any data])Attach a handler to some events for the elements after the descendants have been filtered by 'selector'. The Object 'events' has the form {eventType: function(e), ...}. .one(String eventTypes [,String selector][, Any data], function(Event e) handler).one(Object events [,String selector][, Any data])Identical to .on(...) except that the event handler is unbound after its first invocation, executing at most once. .off() remove all handlers.off(String eventTypes [,String selector] [, function(Event e) handler]) .off(Object events [,String selector])Remove an event handler for the elements. .trigger(String/Event eventType[,Object/Array param]) Execute all handlers for the given event type. .triggerHandler(String eventType[, Array param]) Identical to .trigger(...) except here: 1) the default behavior of an event does not occur. 2) only the first matched element is affected. 3) the event does not bubble up. 4) the return value of the last handler is returned instead of the jQuery object. |
*** The eventType "click.myPlugin.simple" defines both the myPlugin and simple namespaces for this particular click event. |
RESETRUNFULL
<!DOCTYPE html><html><head>
<script src="jquery-3.5.1.min.js"></script></head><body>
<p></p>
<button>Click</button>
<script> // 1.
$(window).on('load',function(){alert('Hi');}); // 2.
$('button').on('focus keydown',function(e){
$('p').text('Key '+(e.which)+
' has been pressed.');
}).on('mouseenter', function(){
$('p').text("Here we go!");
}).on('mouseout', function(){
$('p').text("Don't leave me!");
}).on({mousedown: function(e,x,y){
$('p').text('Button down! '+x);},
mouseup: function(){
$('p').text('Button up!');}});
$('button').off('mouseup')
.trigger('mousedown',[10,20]); // 3.
var e = $.Event('myEvent');
e.v1 = 1000;
e.v2 = 2000;
$('button').on('myEvent', function(e,x,y){
alert(1000+2000);})
.trigger(e);
</script> </body></html>