jquery - Why does a button and a keypress with same function work different? -
i want achieve same result in keypress event "enter" works me on button , somehow keypress duplicates information based on number of times "enter" pressed.
first time shows information correctly , 2nd time doubled, 3rd time 3 times, etc...
$(document).on('keypress', '.dataa', function (event) { if (event.which === 13) { event.preventdefault(); save_data(); } }); and function works correctly if used on button:
function save_data() { var final=''; var datas=''; var spans=$("body").find('#'+pruebaa).attr("data"); $(".dataa").each(function() { if(!!$(this).val()){ datas+=$(this).val()+"-"; } }); final=spans+datas; $(".tabla").remove(); dlg.remove(); $("body").find('#'+pruebaa).attr("data",final); } the problem seems data's part since part doubled 2nd time, tripled 3rd, etc...
Comments
Post a Comment