簡體   English   中英

如何使此功能一次可用於我的html頁面?

[英]How do I make this function work for a single time for my html page?

$(document).ready(function() {    // show popup when you click on the link

   $('.show-popup').hover(function(event){

      event.preventDefault(); // disable normal link function so that it doesn't refresh the page

      var docHeight = $(document).height(); //grab the height of the page

      var scrollTop = $(window).scrollTop(); //grab the px value from the top of the page to where >you're scrolling
      var selectedPopup = $(this).data('showpopup'); //get the corresponding popup to show

      $('.overlay-bg').show().css({ 'height' : docHeight }); //display your popup background and set >height to the page height
      $('.popup' + selectedPopup).show().css({ 'top': scrollTop + 20 + 'px' }); //show the appropriate popup >and set the content 20px from the window top

   }   

});

嘗試這個..

 $('.show-popup').hover(function(event){

      event.preventDefault(); // disable normal link function so that it doesn't refresh the page

      var docHeight = $(document).height(); //grab the height of the page

      var scrollTop = $(window).scrollTop(); //grab the px value from the top of the page to where >you're scrolling
      var selectedPopup = $(this).data('showpopup'); //get the corresponding popup to show

      $('.overlay-bg').show().css({ 'height' : docHeight }); //display your popup background and set >height to the page height
      $('.popup' + selectedPopup).show().css({ 'top': scrollTop + 20 + 'px' }); //show the appropriate popup >and set the content 20px from the window top

      $('.show-popup').unbind('mouseenter mouseleave'); //unbind the event handler
   }   

嘗試這個

$(document).ready(function() {    // show popup when you click on the link

   $('.show-popup').hover(function(event){

      event.preventDefault(); // disable normal link function so that it doesn't refresh the page

      var docHeight = $(document).height(); //grab the height of the page

      var scrollTop = $(window).scrollTop(); //grab the px value from the top of the page to where >you're scrolling
      var selectedPopup = $(this).data('showpopup'); //get the corresponding popup to show

      $('.overlay-bg').show().css({ 'height' : docHeight }); //display your popup background and set >height to the page height
      $('.popup' + selectedPopup).show().css({ 'top': scrollTop + 20 + 'px' }); //show the appropriate popup >and set the content 20px from the window top
      $(this).removeClass("show-popup");

   }   

});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM