javascript - Jquery event listener basic understanding -


i wanted fuller understanding of how javascript handles events. click() triggers div pop up, once div closed doesn't respond event again. way keep event loop going?

    $project.click(function() {          $popup = $(".popup");             $np.hide();     $popup.append($html);      // exit popup         $(document).bind('keydown',function(e) {          if (e.which == 27) {              $popup.hide();             $np.show("slow");         }     });         $(".exitbutton").click(function() {              $popup.hide();             $np.show("slow");        }); }); 

if .popup element set display:none @ page load, can try using .toggle() @ $project click handler. defined $popup , moved keydown event outside of click handler, appears added event handler @ each click of $project

var $popup = $(".popup"); $project.click(function() {      $np.toggle();     $popup.append($html).toggle(); });  // exit popup $(document).bind("keydown",function(e) {      if (e.which == 27) {          $popup.hide();         $np.show("slow");     } });  $(".exitbutton").click(function() {      $popup.hide();     $np.show("slow");    }); 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -