SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2013
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Show image when you can scroll in my div

    Hello,

    I have a div that is filled with dynamic content. So the size is not the same all the time. Sometimes it has a scollbar and sometime it doesnt. When is has a scrollbar I want to let the user know by adding a small image at the bottom (a small bouncing arrow).

    Somehow I cant get that working properly...

    This is what I got now...

    My javascript:

    Code:
    <script type="text/javascript">
    $(window).load(function(){alert($('#scroller').height());})
    
    
    if ( $('#scroller').height() < 1051) {
    
    }
    else {
       document.write('<div class="scroll"><p><img src="http://www.website.nl/showroom/pijl.gif" alt=""/></p></div>');
    }
    
    </script>
    And this is my css:

    Code:
    #scroller
    {
        height:auto;
    }
    When I use the alert function it is showing me diffrent heights but the if function does not work...

    Can somebody help me out

    Thank in advance

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    51
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is not question for PHP, but rather for JavaScript. However, I don't know why wouldn't this work. Can you set up a working example on e.g. http://jsfiddle.net/?

    And also, I wouldn't recommend using document.write(). Instead, place that HTML in the code and hide it (CSS display: none;) and then show it with jQuery in if function ($('.scroll').show();)


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •