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:

http://jsfiddle.net/jcrl7ocn/

$('.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 .length use slidedown() opening "contacts_info" , slideup() closing it.
  • if index greater half of list's .length use slideup() opening "contacts_info" , slidedown() closing it.

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -