click - Javascript - prompt keeps coming back after Ok is pressed -
i have following javascript configuration. works when loads , keeps working first time click on button id buttonkernel
. should run function onpageload
, resets grid presented on screen , reload event handlers. second time click button thought, after clicking ok on prompt, keeps prompting again. if insist, work. i'm new javascript, don't know if self calling function can @ root of problem.
$(document).ready(function(){ onpageload(16); }); function onpageload(size){ gendiv(size); $('.gridsquare').hover(function(){ $(this).css('background-color', 'red'); }); $('#buttonkernel').click(function(){ $(".gridsquare").css('background-color', 'yellow'); var input = prompt ("enter size grid", "16"); size = checkinp(input); var list = document.getelementsbyclassname("row"); (var = list.length - 1; 0 <= i; i--) { if (list[i] && list[i].parentelement) list[i].parentelement.removechild(list[i]); }; onpageload(size); }); }
every time click, add click event handler.
Comments
Post a Comment