JS Scroller

Discussion in 'JavaScript' started by cancer10, Jul 14, 2009.

  1. #1
    HI

    Please consider the code below. Its a table containing images in rows and columns which is wrapped by a DIV tag. The width of the DIV tag is 300px and overflow set to hidden. Is there anyway I can scroll the contents of the DIV tag to right and left with the links Scroll Left and Scroll Right with javascript? Or is there any javascript that can do this trick for me?

    Many thanks



    <a href="#">Scroll Left</a> | <a href="#">Scroll Right</a> 
    <BR><BR>
    <div style="width:300px; overflow:hidden; border:3px solid #000;">
    <table width="100%" border="1" cellspacing="0" cellpadding="5">
      <tr>
        <td><img src="http://static.flickr.com/75/199481072_b4a0d09597_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/69/199481255_fdfe885f87_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/58/199481218_264ce20da0_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/75/199481072_b4a0d09597_s.jpg" width="75" height="75" alt="" /></td>
      </tr>
      <tr>
        <td><img src="http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/77/199481108_4359e6b971_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/57/199481087_33ae73a8de_s.jpg" width="75" height="75" alt="" /></td>
        <td><img src="http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg" width="75" height="75" alt="" /></td>
      </tr>
    </table>
    </div>
    Code (markup):

     
    cancer10, Jul 14, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    i wrote a mootools scroller class, perhaps you can take some ideas from it / mod it for your own use:

    http://fragged.org/dev/scroller.php

    of course, if you don't use mootools then fair enough :)
     
    dimitar christoff, Jul 17, 2009 IP