jquery - slide table content from right to left -
i'm using following http://jsfiddle.net/zsffs/27/ in exaample won't slide attach code below please verify , let me know mistake made, can't able found mistake
<html> <head> <style type="text/css"> .container{ width:500px; height:250px; overflow:hidden; margin:10px; position:relative } .table{ position:absolute; width:2000px; height:250px; left:0; background: -moz-linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet); } </style> <script type="text/javascript"> $('.next').click(function(event){ if($('.table').css('left') != '-1500px') { $(this).prop('disabled', true) $('.table').animate({left:'-=500px'}, 500, function() { $('.next').prop('disabled', false) }); } }); $('.prev').click(function(event){ if($('.table').css('left') != '0px') { $(this).prop('disabled', true) $('.table').animate({left:'+=500px'}, 500, function() { $('.prev').prop('disabled', false) }); } }); </script> </head> <body> <div class="container"> <div class="table"> <table border="2"> <tr> <td>sam</td> <td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td> <td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>man</td><td>man</td><td>man</td><td>sam</td><td>sam</td><td>sam</td><td>sam</td><td>bool</td> </tr> </table> </div> </div> <input type='button' class="prev" value='prev'> <input type='button' class="next" value='next'> </body> </html>
it works in http://jsfiddle.net/zsffs/27/ in advance
you have omitted $(document).ready(function(){ });
, inclusion of jquery framework:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('.next').click(function(event){ if($('.table').css('left') != '-1500px') { $(this).prop('disabled', true) $('.table').animate({left:'-=500px'}, 500, function() { $('.next').prop('disabled', false) }); } }); $('.prev').click(function(event){ if($('.table').css('left') != '0px') { $(this).prop('disabled', true) $('.table').animate({left:'+=500px'}, 500, function() { $('.prev').prop('disabled', false) }); } }); }); </script>
Comments
Post a Comment