javascript - jQuery: Do I need both keyUp and change events? -
i have page 2 forms; each form has input text field;
the value found in input text of 1st form must same value found in input text of 2nd form;
when value chages, other input text field modifies value;
should use both onkeyup
, onchange
events?
if not, wich 1 right 1 use?
i asking because seams have 2 post requests, , think why.
$('input.searchbox').keyup( function(){ $('input.txtfieldsearch').val($('input.searchbox').val()); listviewupdate(); $('input.txtfieldsearch').trigger("keyup"); }); $('input.txtfieldsearch').keyup( function(){ $('input.searchbox').val($('input.txtfieldsearch').val()); listviewupdate(); }); $('input.searchbox').change( function(){ $('input.txtfieldsearch').val($('input.searchbox').val()); listviewupdate(); $('input.txtfieldsearch').trigger("change"); }); $('input.txtfieldsearch').change( function(){ $('input.searchbox').val($('input.txtfieldsearch').val()); listviewupdate(); });
you can use $.on()
function , attach multiples handlers.
$("#element").on('keyup change', function (){ // stuff... });
Comments
Post a Comment