Answer the question
In order to leave comments, you need to log in
How to set a condition for block height?
How to add a class if the height of the sub-menu block is more than 140px and not add a class if it is less?
<ul class="menu">
<li>144</li>
<ul class="sub-menu">
<li>123</li>
<li>123</li>
<li>123</li>
<li>123</li>
<li>123</li>
<li>123</li>
<li>123</li>
<li>123</li>
</ul>
<li>155</li>
<ul class="sub-menu">
<li>123</li>
<li>123</li>
</ul>
</ul>
$( document ).ready(function() {
height = $('.sub-menu').height();
if (height > 120) {
$('.sub-menu').addClass('scroll')
}
else{
$('.sub-menu').removeClass('scroll')
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question