jQuery addClass if div height changes
I have a div that has an expandable list in it. The div has a max-height
of 450px on it so that the list doesn't expand beyond that. I have a set
of arrows on the div that scroll the div up and down on click, but I need
to add up/down arrows to the div only if it's height reaches 450px. Here
is what I have so far...
<script type="text/javascript">
$("#sidebar-container").addEventListener("overflow", function(){
if($("#sidebar-container").height() == 450) {
$('.sidebar-arrow-up').addClass('arrow-show');
$('.sidebar-arrow-down').addClass('arrow-show');
}
else{
$('.sidebar-arrow-up').removeClass('arrow-show');
$('.sidebar-arrow-down').removeClass('arrow-show');
}
},false);
</script>
I have tried on click event, but need this to check the height of the div
without a user driven event.
link:
http://shamounwp.theinfiniteclients.com/procedures/breast/types-of-procedures/choiceswhich-one-is-right-for-me/
No comments:
Post a Comment