jquery:paste-event-not-working
jQuery paste event not working
In this example I wanted to do somenthing every time the input value is changed by typing, pasting or set by code from another event.
$('#foo [name="vid"]').on('change keyup paste', function(){ if($(this).val()){ //do something } });
Unfortunately that obvious and intuitive solution is not going to work. To solve the problem.
$('#foo [name="vid"]').on('change keyup paste', function(){ let $self=$(this); setTimeout(function(){ if($self.val()){ //do something } }, 0); });
setTimeout could be set with a greater value than zero with the advantage of not doing something heavy at every keypress. So, 2 birds with a stone.
jquery/paste-event-not-working.txt · Last modified: 2022/10/03 19:05 by rik