jQuery preventDefault() is not working after each function -
i'm trying input form using each function. preventdefault not working after each function.
$("#my-form").on('submit', function(e){ var masterarray = array(); var stringify = ''; $(".input-class").each(function(){ $id = $(this).attr('id'); $data = $(this).val(); $myarray = array(); if ($eamount == 0) { myarray = { scheme_code:$id, amount:0 }; }else{ myarray = { scheme_code:$id, amount:$data }; } masterarray.push(myarray); }); stringify = json.stringify(investmentarray); e.preventdefault(); )};
you should use e.preventdefault()
after event binding
$("#my-form").on('submit', function(e){ e.preventdefault(); // rest stuff });
Comments
Post a Comment