Answer the question
In order to leave comments, you need to log in
Why doesn't hide() work?
Have HTML
<div class="settings__category">
<div class="category-show__btn">
<span>Все категории</span>
<div class="category-show__overlay"></div>
<div class="category-show__dropdown">
<div class="category-show__header">
<span class="category-show__title">Все категории</span>
<span class="category-show__close"><i class="fa fa-times" aria-hidden="true"></i></span>
</div>
<ul class="category-show__cat-list">
<li>....</li>
<li>....</li>
.....
<li>....</li>
</ul>
</div>
</div>
</div>
jQuery(document).ready(function($) {
$('.category-show__btn').on('click', function() {
$(this).children('.category-show__overlay').show();
$(this).children('.category-show__dropdown').show();
});
$('.category-show__close').on('click', function() {
$(this).closest('.category-show__dropdown').hide();
$(this).closest('.category-show__dropdown').prev('.category-show__overlay').hide();
});
$('.category-show__overlay').on('click', function() {
$(this).hide();
$(this).next('.category-show__dropdown').hide();
});
})
Answer the question
In order to leave comments, you need to log in
hide() works for you. But first $('.category-show__close').on('click', function() { , and then for the ancestor $('.category-show__btn').on('click', function() { .
That is, in a fraction of a second, your blocks are hidden, and then reappear.Set
the time to 1000ms everywhere and you will see:
jQuery(document).ready(function($) {
$('.category-show__btn').on('click', function() {
$(this).children('.category-show__overlay').show(1000);
$(this).children('.category-show__dropdown').show(1000);
});
$('.category-show__close').on('click', function() {
$(this).closest('.category-show__dropdown').hide(1000);
$(this).closest('.category-show__dropdown').prev('.category-show__overlay').hide(1000);
});
$('.category-show__overlay').on('click', function() {
$(this).hide(1000);
$(this).next('.category-show__dropdown').hide(1000);
});
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question