$(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
}
});
0
A
回答
0
試試這個..
$('.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
}
0
試試這個
$(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");
}
});
+0
謝謝SimarjeetSingh。 你能回答嗎? https://answers.yahoo.com/question/index?qid=20150113204233AAdUMvB – Prakhar
相關問題
- 1. 如何使這些功能在同一頁上工作
- 2. 如何讓兩個javascripts在一個頁面上工作
- 3. 我工作在這個C++代碼上,不能讓它工作......看下面
- 4. 如何讓這個功能重定向到給定的html頁面?
- 5. 調用一個html頁面上這個當工作不正常
- 6. 媒體查詢不能在一個頁面上工作html
- 7. 如何讓我的頁面記住用戶的上次操作?
- 8. 如何讓Facebook應用只在我的頁面上工作?
- 9. 這個功能是如何工作的?
- 10. 這個功能是如何工作的?
- 11. 這個功能是如何工作的?
- 12. 這個功能是如何工作的?
- 13. 這個功能是如何工作的?
- 14. jQuery不能在我的HTML頁面上工作
- 15. 如何阻止功能一次工作?
- 16. 我如何使一個頁面ror網站與所有的crud功能工作?
- 17. 我不能讓這個頁腳留在頁面的最底部
- 18. chartjs不工作的PHP頁面,但在HTML頁面上工作
- 19. HTML頁面正在工作,但aspx頁面不能在IIS上工作
- 20. 如何讓CAPTCHA在多個頁面上工作?
- 21. 如何讓iron-a11y-keys在整個頁面上工作?
- 22. 如何讓htaccess在每個頁面上工作
- 23. 這個功能如何工作?
- 24. 這個功能如何工作? - Oracle
- 25. 這個「日月」功能如何工作?
- 26. 如何使wordpress功能只能在單頁和非頁面上工作
- 27. 我如何在同一頁面使用這個Javascript兩次
- 28. 具有「yield」功能的這個功能是如何工作的?
- 29. 如何使這個滾動功能在jQuery上工作?
- 30. 頁面上的兩個jQuery應用程序一次只能工作一個?
單時間是指究竟是什麼?每頁一次,每週一次,曾經有一次?您需要了解本地存儲或cookie,或者更好地瞭解服務器端代碼以記住狀態並添加代碼。如果它是每頁一次,那麼你只是解除綁定事件。 – epascarello
在執行完成後取消綁定事件。 –
[jQuery中的['one'](http://api.jquery.com/one/)方法怎麼樣? –