jQuery: How to trigger "e" in function(e) { ... }? -
i have 1 master text field, , want when user types text field text fields class variant_price
updated same text.
i have done:
$("#master_price").keypress(function (e) { $(".variant_price").val($(this).val()); });
however, on first keypress, seems fire off $(".variant_price").val($(this).val());
part before e
happens, when type 123
variant_price
text fields updated 23
without first keypress (1
).
how trigger e before line? there e.fire()
?
according use case you've described, looking change
event rather keypress
(a field can modified pasting via mouse button, example).
also, don't need event object (e
) @ all.
$("#master_price").change(function() { $(".variant_price").val($("#master_price").val()); });
if want instant reaction change, may bind same handler multiple events without storing function temporary, follows:
$("#master_price").on("change keyup", function() { $(".variant_price").val($("#master_price").val()); })
Comments
Post a Comment