I'm using this html & jquery I found on another question and it works well, with one exception.
It shows and hides divs and this works well unless the div is near the bottom of the screen then it is shown but part of it is off screen.
Is there anyway to update this code so if the DIV is partly off screen the page is automatically scrolled so it comes into view ?
HTML :
<ul id="list">
<li>
<a href="#" class="togglelink">America</a>
<div class="toggle" style="display: block;">
<p>America - USA - the States</p>
</div>
</li>
<li>
<a href="#" class="togglelink">Brazil</a>
<div class="toggle" style="display: block;">
<p>Brazil - Federative Republic of Brazil</p>
</div>
</li>
</ul>
JS :
$(document).ready(function () {
$('.toggle').hide();
$('a.togglelink').on('click', function (e) {
e.preventDefault();
var elem = $(this).next('.toggle')
$('.toggle').not(elem).hide('slow');
elem.toggle('slow');
});
});
Obviously any other div that is shown and isn't off screen shouldn't be affected.
many thanks:-D