Event handling is a coding style about handling messages between a source and one or more subscribers. A point listener in the source provide a way which subscribed code can consume messages raised from the source.
Questions tagged [event-handling]
12746 questions
3228
votes
14 answers
event.preventDefault() vs. return false
When I want to prevent other event handlers from executing after a certain event is fired, I can use one of two techniques. I'll use jQuery in the examples, but this applies to plain-JS as well:
1. event.preventDefault()
$('a').click(function (e) {
…

RaYell
- 69,610
- 20
- 126
- 152
886
votes
9 answers
window.onload vs document.onload
Which is more widely supported: window.onload or document.onload?

Chris Ballance
- 33,810
- 26
- 104
- 151
752
votes
13 answers
jQuery checkbox checked state changed event
I want an event to fire client side when a checkbox is checked / unchecked:
$('.checkbox').click(function() {
if ($(this).is(':checked')) {
// Do stuff
}
});
Basically I want it to happen for every checkbox on the page. Is this method of…

AnonyMouse
- 18,108
- 26
- 79
- 131
697
votes
21 answers
jQuery checkbox change and click event
$(document).ready(function() {
//set initial state.
$('#textbox1').val($(this).is(':checked'));
$('#checkbox1').change(function() {
$('#textbox1').val($(this).is(':checked'));
});
$('#checkbox1').click(function() {
if…

Professor Chaos
- 8,850
- 8
- 38
- 54
635
votes
22 answers
UITextField text change event
How can I detect any text changes in a textField? The delegate method shouldChangeCharactersInRange works for something, but it did not fulfill my need exactly. Since until it returns YES, the textField texts are not available to other observer…

karim
- 15,408
- 7
- 58
- 96
618
votes
15 answers
How to debug JavaScript / jQuery event bindings with Firebug or similar tools?
I need to debug a web application that uses jQuery to do some fairly complex and messy DOM manipulation. At one point, some of the events that were bound to particular elements, are not fired and simply stop working.
If I had a capability to edit…

Jaanus
- 17,688
- 15
- 65
- 110
581
votes
2 answers
How can I trigger an onchange event manually?
I'm setting a date-time textfield value via a calendar widget. Obviously, the calendar widget does something like this :
document.getElementById('datetimetext').value = date_value;
What I want is:
On changing value in the date-time textfield I need…

CodeTweetie
- 6,075
- 3
- 19
- 23
386
votes
16 answers
Why are only final variables accessible in anonymous class?
a can only be final here. Why? How can I reassign a in onClick() method without keeping it as private member?
private void f(Button b, final int a){
b.addClickHandler(new ClickHandler() {
@Override
public void…
user467871
363
votes
13 answers
Understanding events and event handlers in C#
I understand the purpose of events, especially within the context of creating user interfaces. I think this is the prototype for creating an event:
public void EventName(object sender, EventArgs e);
What do event handlers do, why are they needed,…

Levi Campbell
- 6,005
- 7
- 40
- 47
316
votes
10 answers
Difference between e.target and e.currentTarget
I don't understand the difference, they both seem the same but I guess they are not.
Any examples of when to use one or the other would be appreciated.

Artemix
- 8,497
- 14
- 48
- 75
314
votes
9 answers
jQuery - Detect value change on hidden input field
I have a hidden text field whose value gets updated via an AJAX response.
When this value changes, I would like to fire an AJAX request. Can anyone advise on how to detect the change?
I have…

Ben
- 6,026
- 11
- 51
- 72
300
votes
2 answers
How can I capture the right-click event in JavaScript?
I want to block the standard context menus, and handle the right-click event manually.
How is this done?

Giffyguy
- 20,378
- 34
- 97
- 168
297
votes
11 answers
How to call function on child component on parent events
Context
In Vue 2.0 the documentation and others clearly indicate that communication from parent to child happens via props.
Question
How does a parent tell its child an event has happened via props?
Should I just watch a prop called event? That…

jbodily
- 3,613
- 2
- 20
- 21
276
votes
3 answers
JavaScript click handler not working as expected inside a for loop
I'm trying to learn JS and got an issue.
I tried many things and googled but all in vain. Following piece of code doesn't work as expected. I should get value of i on click but it always returns 6. I'm pulling my hair out; please help.
for (var i =…

JS-coder
- 3,243
- 2
- 14
- 14
275
votes
14 answers
Android: Difference between onInterceptTouchEvent and dispatchTouchEvent?
What is the difference between onInterceptTouchEvent and dispatchTouchEvent in Android?
According to the android developer guide, both methods can be used to intercept a touch event (MotionEvent), but what is the difference?
How do…

Anne Droid
- 3,151
- 4
- 16
- 15