javascript - navigation list issue -
i working on small application below there collection of list items list items should within box no matter how many can on second column. want keep limit on number of list items can displayed not more 10 moment there 10 items 10th item should omitted , "view all" should displayed. once user clicks on view can directed second page , items can displayed.
below code.
thanks
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <style>     #container {  border: 1px dotted #d7d7d7;  padding: 0px 5px 5px 8px;  height: 250px;  width: 250px;   }    #heading {  } ul {     display: inline; } ul li{     display: block; }  </style> </head> <div id="container">     <div id="heading">style </div>     <ul>         <li> >>1 </li>         <li> >>2 </li>         <li> >>3 </li>         <li> >>4 </li>         <li> >>5 </li>         <li> >>6 </li>      </ul>    </div> <body> </body> </html>      
if you're looking limit amount of items displayed can fixed width on list items , overflow hidden clip additional items being displayed.
<style>    ul {         height: 20px;         overflow: hidden;         width: 180px;       }     li {         display: block;         float: left;         height: 20px;         width: 20px;       }     ul.unlimited {        height: auto;      }     #view_all {        display: none;    } </style>   no displaying view link. advise generating on server side. if don't have control on that, can javascript example make simple jquery script:
<script>         $(document).ready(function() {           if ($("#container ul li").length > 9) {             $("#view_all").show().click(function() {               $("#container ul").addclass("unlimited");               return false;             });           }         }); </script>   here i'm assuming have anchor embedded in html id of "view_all". can see we're doing here. css hides view link default , uses fixed width , height on list. if there more 10 items won't visible default styling permits 9 shown. however, jquery script tell web browser make view link visible. assign click event handler on link. applies class list removes fixed height allowing of list items displayed.
you can handle in variety of different ways 1 simple solution. note want add id or class unsorted list bit more explicit in css/js code.
Comments
Post a Comment