jquery - How can I make a <div> to grow upwards if its at the bottom of container <div>? -
what trying when div "contacts" clicked, div "contacts_info" show/hide have achieved.
the problem when item @ bottom of list clicked grow downward , list scroll in container , grow upwards "contacts_info" shown , no need scroll down.
below code:
$('.contacts').on('click', function() { var next = $(this).next('.contacts_info'); next.slidetoggle(300); $('.contacts_info').not(next).slideup(300); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="parent"> <div id="con_contacts"> <ul> <li> <div class="contacts"> <table style="width: 100%; padding: 10px;"> <tr> <td class="td_left">somers</td> <td class="td_right">3 feb 15</td> </tr> <tr> <td class="td_left">new unit trust launch</td> <td class="td_right">marketing</td> </tr> </table> </div> <div class="contacts_info"> asf </div> </li> ... </ul> </div> </div>
you need put index in list , track index:
- if index smaller half of list's
.lengthuseslidedown()opening "contacts_info" ,slideup()closing it. - if index greater half of list's
.lengthuseslideup()opening "contacts_info" ,slidedown()closing it.
Comments
Post a Comment