You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When is the change event triggered? As described in the documentation: change event is fired for <input>, <select>, and <textarea> elements when an alteration to the element's value is committed by the user. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value.
When I've an input element:
<inputid="test" type="text"/>
And have the following code:
constinput=document.querySelector('#test');input.value='Programmatically set value';input.addEventListener('change',()=>{console.info('the change event was triggered!');});
The change event will be triggered when the user manually clears the input field. Happy days! But when we set the value using the setAttribute function, no change event will be triggered when the user clears the input element.
constinput=document.querySelector('#test');input.setAttribute('value','Programmatically set value');input.addEventListener('change',()=>{console.log('the change event was never triggered!');});
With both implementations, it is the user who clears the input element. I would expect an event in both cases. It looks like a bug?
The text was updated successfully, but these errors were encountered:
When is the change event triggered? As described in the documentation:
change event is fired for <input>, <select>, and <textarea> elements when an alteration to the element's value is committed by the user. Unlike the input event, the change event is not necessarily fired for each alteration to an element's value.
When I've an input element:
And have the following code:
The change event will be triggered when the user manually clears the input field. Happy days! But when we set the value using the setAttribute function, no change event will be triggered when the user clears the input element.
With both implementations, it is the user who clears the input element. I would expect an event in both cases. It looks like a bug?
The text was updated successfully, but these errors were encountered: