0

So, I have a set of inputs and I need that when certain function is executed it loops all of the inputs and the triggers a keypress event. I do not need just to change the value, I need the keypress event because each input has a "onkeypress" event that I need it to respond to.

HTML:

<div id"myinputs">
<input name="name" onkeypress="return myfunction(this)" />
<input name="name1" onkeypress="return myfunction(this)" />
<input name="name2" onkeypress="return myfunction(this)" />
<input name="name3" onkeypress="return myfunction(this)" />
<input name="name4" onkeypress="return myfunction(this)" />
</div>

jQuery

var e = jQuery.Event("keypress");
e.which = 55;
e.keyCode = 55;
$("#myinputs").each(function(index, element)){
$(element).trigger(e);
});

I hope you guys can help! Thank you!

andres.gtz
  • 624
  • 12
  • 22

0 Answers0