javascript - Slider Buttons that Hide and Reveal CSS Overflow -
i'm looking javascript code enables user alternately click button display unordered list , click hide first element of list. default overflowed content hidden owing styling of unordered list. i'm hoping achieve result similar -webkit-paged-x
except without vertical or horizontal scrollbar appearing.
ul{ overflow:hidden; height:20px; width: 20px; } li{ float:left; width:30px; }
<!doctype html> <head> </head> <body> <input type="button" value="<"><input type="button" value=">"> <ul> <li>a</li> <li>b</li> <li>c</li> <li>d</li> <li>e</li> <li>f</li> </ul> </body> </html>
i guess following snippet work. when clicking right arrow button overflow show no scroll; when clicking left arrow button content inside list element return overflow:hidden
.
$(document).ready(function(){ $('input').attr('type','button').click(function(){ $('ul').css( 'overflow', 'hidden'); }); $('input').attr('type','button').next().click(function(){ $('ul').css( 'overflow', 'visible'); }); });
ul{ overflow:hidden; height:20px; width: 20px; } li{ float:left; width:30px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!doctype html> <head> </head> <body> <input type="button" value="<"><input type="button" value=">"> <ul> <li>a</li> <li>b</li> <li>c</li> <li>d</li> <li>e</li> <li>f</li> </ul> </body> </html>
i hope helps!
Comments
Post a Comment