Answer the question
In order to leave comments, you need to log in
Confused with jQuery?
https://codepen.io/anon/pen/KvepOw
The situation is as follows, ideally everything should work as follows: when you click on .nav, all content opens, when you click on tabs, only tabs are switched (content is not collapsed), the active class is given item and nav.
I can’t change it in any way so that the click is on nav and at the same time the active class is given for the item that we selected and the nav on which we clicked, respectively, if you poke on the second nav, the last item collapses and the active classes are removed.
Help with advice or correct the code on it, too, I'll understand ...
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
If you want to deploy an application to vue, then it's better to do it through the official CLI.
npm i @vue/cli -g
vue create my-app
cd my-app
npm run serve
The same problem arose yesterday: it turned out to be a bug in the latest version of the node https://github.com/nodejs/node/issues/27379, rolled back - everything worked.
.item {
cursor: pointer;
}
.item.active {
background-color: yellow;
}
.item.active .content{
display: inline-block;
}
.item .content {
display: none;
}
.item .nav.active {
background-color: blue;
display: inline-block;
}
.item .content .tabs .tab {
display: inline-block;
}
.item .content .for-tabs .cont:first-child {
display: block;
}
.item .content .for-tabs .cont {
display: none;
}
$('.item').click(function() {
$('.item').not($(this)).removeClass('active');
$(this).toggleClass('active');
});
$(".tab").click(function(e) {
var ind = $(this).index();
$(".tab").removeClass("active");
$(".cont").hide();
$(this).addClass("active").closest(".content").find(".cont").eq(ind).show();
e.stopPropagation();
});
I took your example, completely rewrote JS and slightly styles. All clear?
Result
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question