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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -