19

why this doesn´t work:

inputButton.addEventListener('onchange', jsFunction, false);

I change the inputbox and it doesn´t call jsFunction.

1 Answer 1

43

Try change instead of onchange

inputButton.addEventListener('change', jsFunction, false);
Sign up to request clarification or add additional context in comments.

1 Comment

Expanding: We're used to the DOM0 names onchange, onload, etc. Those were the names of the attributes we used back in the day. The standard DOM2 stuff does away with the "on" part -- so, change, load, etc. IE's non-standard DOM2 equivalent, attachEvent, retains the "on". So the rule is, with addEventListener, there's no "on"; with just about everything else, there is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.