English 中文(简体)
在高校对超文件高度进行调整后,我怎么能够出现/消失?
原标题:How do I get a element to appear/disappear once HTML document height is adjusted, in JQuery?
  • 时间:2011-01-06 12:46:49
  •  标签:
  • jquery

见下文准则。

目标: 如果浏览器窗户有垂直的滚动,则显示 #头......暗中点 #。

问题: 我的网页上有一些内容,因此,我可以探讨调整页数,因此,如果浏览器的滚滚动锁明显或没有可见,就会受到影响。

问题:如果我倒塌/把页和安放上的所有要素gle倒起来,我怎么会消失?

var hContent = $("body").height(); 
var hWindow = $(window).height(); 

if(hContent>hWindow) {
    $( #scroll-top ).fadeIn(250);    
}
else {
    $( #scroll-top ).fadeOut(250);
}

任何帮助都得到了广泛接受, 增 编

最佳回答

为什么不要把你的榜样守则放在一个职能中,在你试图分析你的内容以确定你是否需要展示或隐藏<条码>。

function ToggleScrollTop() {
   var hContent = $("body").height(); 
   var hWindow = $(window).height(); 

   if(hContent>hWindow) {
       $( #scroll-top ).fadeIn(250);    
   }
   else {
       $( #scroll-top ).fadeOut(250);
   }  
}
问题回答
function scrollTopCheck() {

      if(hContent>hWindow) {
        $( #scroll-top ).fadeIn(250);    
      }
      else {
          $( #scroll-top ).fadeOut(250);
      }
    }  




setInterval(500, scrollTopCheck); //this would call scrollTopCheck function every 1/2 second

然而,它最好确定对美元吸引力的回扣( 回顾<>>)。

$( .elementsToToggle ).toggle(scrollTopCheck);




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...