Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jQuery event methods

bind(): 								Deprecated in version 3.0. Use the on() method instead. Attaches event handlers to elements
blur(): 								Attaches/Triggers the blur event
change():								Attaches/Triggers the change event
click(): 								Attaches/Triggers the click event
dblclick():								Attaches/Triggers the double click event
delegate():								Deprecated in version 3.0. Use the on() method instead. Attaches a handler to current, or future, specified child elements of the matching elements
die():  								Removed in version 1.9. Removes all event handlers added with the live() method
error():								Removed in version 3.0. Attaches/Triggers the error event
event.currentTarget:					The current DOM element within the event bubbling phase
event.data								Contains the optional data passed to an event method when the current executing handler is bound
event.delegateTarget:					Returns the element where the currently-called jQuery event handler was attached
event.isDefaultPrevented():				Returns whether event.preventDefault() was called for the event object
event.isImmediatePropagationStopped():	Returns whether event.stopImmediatePropagation() was called for the event object
event.isPropagationStopped():			Returns whether event.stopPropagation() was called for the event object
event.namespace:						Returns the namespace specified when the event was triggered
event.pageX:							Returns the mouse position relative to the left edge of the document
event.pageY:							Returns the mouse position relative to the top edge of the document
event.preventDefault():					Prevents the default action of the event
event.relatedTarget:					Returns which element being entered or exited on mouse movement
event.result:							Contains the last/previous value returned by an event handler triggered by the specified event
event.stopImmediatePropagation():		Prevents other event handlers from being called
event.stopPropagation():				Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event
event.target:  							Returns which DOM element triggered the event
event.timeStamp: 						Returns the number of milliseconds since January 1, 1970, when the event is triggered
event.type: 							Returns which event type was triggered
event.which: 							Returns which keyboard key or mouse button was pressed for the event
focus(): 								Attaches/Triggers the focus event
focusin(): 								Attaches an event handler to the focusin event
focusout(): 							Attaches an event handler to the focusout event
hover(): 								Attaches two event handlers to the hover event
keydown(): 								Attaches/Triggers the keydown event
keypress(): 							Attaches/Triggers the keypress event
keyup(): 								Attaches/Triggers the keyup event
live(): 								Removed in version 1.9. Adds one or more event handlers to current, or future, selected elements
load(): 								Removed in version 3.0. Attaches an event handler to the load event
mousedown(): 							Attaches/Triggers the mousedown event
mouseenter(): 							Attaches/Triggers the mouseenter event
mouseleave(): 							Attaches/Triggers the mouseleave event
mousemove(): 							Attaches/Triggers the mousemove event
mouseout(): 							Attaches/Triggers the mouseout event
mouseover(): 							Attaches/Triggers the mouseover event
mouseup(): 								Attaches/Triggers the mouseup event
off(): 									Removes event handlers attached with the on() method
on(): 									Attaches event handlers to elements
one(): 									Adds one or more event handlers to selected elements. This handler can only be triggered once per element
$.proxy(): 								Takes an existing function and returns a new one with a particular context
ready(): 								Specifies a function to execute when the DOM is fully loaded
resize(): 								Attaches/Triggers the resize event
scroll(): 								Attaches/Triggers the scroll event
select(): 								Attaches/Triggers the select event
submit(): 								Attaches/Triggers the submit event
toggle():								Removed in version 1.9. Attaches two or more functions to toggle between for the click event
trigger():								Triggers all events bound to the selected elements
triggerHandler():						Triggers all functions bound to a specified event for the selected elements
unbind():								Deprecated in version 3.0. Use the off() method instead. Removes an added event handler from selected elements
undelegate():							Deprecated in version 3.0. Use the off() method instead. Removes an event handler to selected elements, now or in the future
unload():								Removed in version 3.0. Attaches an event handler to the unload event
Comment

jQuery Event Methods

//click()
$("p").click(function(){
  $(this).hide();
});

//dblclick()
$("p").dblclick(function(){
  $(this).hide();
});

//mouseenter()
$("#p1").mouseenter(function(){
  alert("You entered p1!");
});

//mouseleave()
$("#p1").mouseleave(function(){
  alert("Bye! You now leave p1!");
});

//mousedown()
$("#p1").mousedown(function(){
  alert("Mouse down over p1!");
});

//mouseup()
$("#p1").mouseup(function(){
  alert("Mouse up over p1!");
});

//hover()
$("#p1").hover(function(){
  alert("You entered p1!");
},
function(){
  alert("Bye! You now leave p1!");
});

//focus()
$("input").focus(function(){
  $(this).css("background-color", "#cccccc");
});

//blur()
$("input").blur(function(){
  $(this).css("background-color", "#ffffff");
});

//The on() Method
$("p").on("click", function(){
  $(this).hide();
});

//Example
$("p").on({
  mouseenter: function(){
    $(this).css("background-color", "lightgray");
  },
  mouseleave: function(){
    $(this).css("background-color", "lightblue");
  },
  click: function(){
    $(this).css("background-color", "yellow");
  }
});
Comment

jQuery Event Methods

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>

<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>

</body>
</html>
Comment

jQuery Event Methods

bind()	Deprecated in version 3.0. Use the on() method instead. Attaches event handlers to elements
blur()	Attaches/Triggers the blur event
change()	Attaches/Triggers the change event
click()	Attaches/Triggers the click event
dblclick()	Attaches/Triggers the double click event
delegate()	Deprecated in version 3.0. Use the on() method instead. Attaches a handler to current, or future, specified child elements of the matching elements
die()	Removed in version 1.9. Removes all event handlers added with the live() method
error()	Removed in version 3.0. Attaches/Triggers the error event
event.currentTarget	The current DOM element within the event bubbling phase
event.data	Contains the optional data passed to an event method when the current executing handler is bound
event.delegateTarget	Returns the element where the currently-called jQuery event handler was attached
event.isDefaultPrevented()	Returns whether event.preventDefault() was called for the event object
event.isImmediatePropagationStopped()	Returns whether event.stopImmediatePropagation() was called for the event object
event.isPropagationStopped()	Returns whether event.stopPropagation() was called for the event object
event.namespace	Returns the namespace specified when the event was triggered
event.pageX	Returns the mouse position relative to the left edge of the document
event.pageY	Returns the mouse position relative to the top edge of the document
event.preventDefault()	Prevents the default action of the event
event.relatedTarget	Returns which element being entered or exited on mouse movement
event.result	Contains the last/previous value returned by an event handler triggered by the specified event
event.stopImmediatePropagation()	Prevents other event handlers from being called
event.stopPropagation()	Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event
event.target	Returns which DOM element triggered the event
event.timeStamp	Returns the number of milliseconds since January 1, 1970, when the event is triggered
event.type	Returns which event type was triggered
event.which	Returns which keyboard key or mouse button was pressed for the event
focus()	Attaches/Triggers the focus event
focusin()	Attaches an event handler to the focusin event
focusout()	Attaches an event handler to the focusout event
hover()	Attaches two event handlers to the hover event
keydown()	Attaches/Triggers the keydown event
keypress()	Attaches/Triggers the keypress event
keyup()	Attaches/Triggers the keyup event
live()	Removed in version 1.9. Adds one or more event handlers to current, or future, selected elements
load()	Removed in version 3.0. Attaches an event handler to the load event
mousedown()	Attaches/Triggers the mousedown event
mouseenter()	Attaches/Triggers the mouseenter event
mouseleave()	Attaches/Triggers the mouseleave event
mousemove()	Attaches/Triggers the mousemove event
mouseout()	Attaches/Triggers the mouseout event
mouseover()	Attaches/Triggers the mouseover event
mouseup()	Attaches/Triggers the mouseup event
off()	Removes event handlers attached with the on() method
on()	Attaches event handlers to elements
one()	Adds one or more event handlers to selected elements. This handler can only be triggered once per element
$.proxy()	Takes an existing function and returns a new one with a particular context
ready()	Specifies a function to execute when the DOM is fully loaded
resize()	Attaches/Triggers the resize event
scroll()	Attaches/Triggers the scroll event
select()	Attaches/Triggers the select event
submit()	Attaches/Triggers the submit event
toggle()	Removed in version 1.9. Attaches two or more functions to toggle between for the click event
trigger()	Triggers all events bound to the selected elements
triggerHandler()	Triggers all functions bound to a specified event for the selected elements
unbind()	Deprecated in version 3.0. Use the off() method instead. Removes an added event handler from selected elements
undelegate()	Deprecated in version 3.0. Use the off() method instead. Removes an event handler to selected elements, now or in the future
unload()	Removed in version 3.0. Use the on() or trigger() method instead. Attaches an event handler to the unload event
Comment

events jquery

$(".demo").click(function(){
$(this).hide(200);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to use object destructuring 
Javascript :: remove element json javascript 
Javascript :: alert modal 
Javascript :: es6 class example 
Javascript :: getattribute 
Javascript :: js then vs await 
Javascript :: javascript inheritance 
Javascript :: vuejs chatbot widget 
Javascript :: how to hide a button in react 
Javascript :: javascript object as key 
Javascript :: rename files in folder 
Javascript :: how to create object dynamically in javascript 
Javascript :: what is node in selenium grid 
Javascript :: bot react message with custom emoji 
Javascript :: javascript join 2 variables into string 
Javascript :: discord bot not responding to commands 
Javascript :: how to write last element of array 
Javascript :: vue prop using variable 
Javascript :: trim function 
Javascript :: random string javascript 
Javascript :: indexof 
Javascript :: pretty print javascript 
Javascript :: what is a node 
Javascript :: best computer language 
Javascript :: firebase contains query realtime 
Javascript :: mapsort 
Javascript :: import css files maven resources with jsf 
Javascript :: using the for of loop in pure javascript to populate data into HTML 
Javascript :: vs 2019 how to publish angular environment prod 
Javascript :: delete single image by using user id in node js mongodb 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =