Skip to content
Advertisement

Keyup not working for dynamically added input-groups

I have already gone through questions available on this topic and have tried everything, but still my keyup function is not working.

JavaScript
JavaScript

This code works perfectly for the two inputs already in the HTML part. When I click on the “More Option” button the new field gets added but the “keyup” does not work on it. In fact, when I enter something on the new added inputs then my “More Option” & “Submit” button gets disabled (really do’t know why this is happening).

Advertisement

Answer

You’ve to add the class pollOption to the input and not the div in your append :

JavaScript

Instead of :

JavaScript

Demo:

JavaScript
JavaScript
Advertisement