There are lots of questions that seem to be asking this, but in the end all they want is to attach .click events and not .each and so the generally accepted answer in all of them include $("body").on("click", ".selector", function(){});
and this is definitely not what I want.
I have some generated inputs and I need to change the value of each one at the same time. Normally I would $(".inputs").each(function(){$(this).val("new-value")};
or something along those lines, however, I can't because of the dynamic aspect.
So how would you do a $("body").on("each", ".inputs", function(){});
?
Actually, it's as simple as running the .each inside setTimout.
setTimeout(function(){
$(".inputs").each(function(){$(this).val("new-value")});
}, 5000);
$.each
works with any new elements added.
http://jsfiddle.net/4SV7n/
Doing something different each time:
http://jsfiddle.net/4SV7n/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With