Answer the question
In order to leave comments, you need to log in
Appearance of blocks when clicking on a link, hiding when clicking again + add / remove a class?
Dear colleagues, there is a code https://jsfiddle.net/orsc3xs7/
This code is missing, switching the visibility of the submenu and hiding the submenu when clicked again. And closing the submenu when clicking on an empty space
Answer the question
In order to leave comments, you need to log in
You have very specific markup for implementing tabs, but nevertheless https://jsfiddle.net/orsc3xs7/6/
css
.nav-service {
padding: 0;
margin: 0;
list-style: none;
position: relative;
}
.nav-service li {
float: left;
margin-left: 10px;
}
.sub-menu {
position: absolute;
top: 20px;
left: 0px;
visibility: hidden;
opacity: 0;
transition: all ease 0.2s
}
.active+.sub-menu {
visibility: visible;
opacity: 1;
}
$('.nav-button').click(function(e) {
e.stopPropagation();
e.preventDefault();
$('.nav-button').not(this).removeClass('active');
$(this).addClass('active').next().delay(200).show();
});
$('html, .close').click(function() {
if ($('.nav-button.active').length > 0) {
$('.nav-button').removeClass('active').next().delay(200).hide()
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question