Skip to content
Advertisement

Trigger for input is not invoking in jquery

I have a small snippet that changes the textbox size based on its input

I want to use jquery for all functions as much as possible but when I try with

JavaScript

Its not invoking.

JavaScript

Advertisement

Answer

As mentioned in my comment, you were listening for the native input event instead of jQuery’s event system, so when you used trigger to dispatch the event, there was a disconnect and your listener wasn’t firing. Basically you shouldn’t mix the event systems, native and jQuery.

I made the input handler reusable by defining a function handleInput which is now added to your input like .on('input', handleInput).

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement