javascript - Function not being bind at page load -
i trying avoid page being refreshed after submitting form. in order i've added javascript section
$("body").on('click',"#register",new_user_pop); $("body").on('click',"#screen",pop_out); $("body").on('click',"#new-user",pop_registration); $('form[name=new-user-form]').on('submit',function(event) { event.preventdefault(); alert("not refreshing");
the function works in order debug pasted on terminal chrome's developer tools , started working. reason not know not work not loads @ beginning. previous function $("body").on('click')... work fine.
make sure code runs after you've defined html elements want attach events to.
you can either placing script below html bit need.
or can wrap code in onready/load callback:
$(document).ready(function () { /* code goes here */ });
Comments
Post a Comment