I need to show/hide div buttons according to nav-list div height overflow, if list is overflow then show buttons otherwise hide it.
JQuery
// didnt work for me!
if($('#nav-list').prop('scrollHeight') < $('#nav-list').height()){
$('#updown-arrows').hide();
}else{
$('#updown-arrows').show();
}
HTML
<div id="nav-list">
<!-- wordpress nav menu -->
<?php
wp_nav_menu(
array(
'theme_location' => 'primary',
'depth' => 2,
'menu_class' => 'list-unstyled components',
'menu_id' => 'sidebarnav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker()
)
);
?>
</div>
<!-- up/down arrows buttons -->
<div id="updown-arrows">
<a id="up" href="#"><span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span></a>
<a id="down" href="#"><span class="glyphicon glyphicon-menu-down bounce" aria-hidden="true"></span></a>
</div>
if someone faced the same issue
function checkOverflow() {
if ($('#nav-list').prop('scrollHeight') <= $('#nav-list').prop('clientHeight')){
$('#updown-arrows').hide();
} else {
$('#updown-arrows').show();
}
}
checkOverflow();
$(window).resize(function () {
checkOverflow()
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.