Answer the question
In order to leave comments, you need to log in
How to write such code in a compact way?
Guys, js is very bad. There is this script:
$('#cont-one').on('click', function(event) {
$("#one-cont").addClass("activecont")
$("#two-cont").removeClass("activecont")
$("#three-cont").removeClass("activecont")
$("#four-cont").removeClass("activecont")
event.preventDefault();
});
$('#cont-two').on('click', function(event) {
$("#one-cont").removeClass("activecont")
$("#two-cont").addClass("activecont")
$("#three-cont").removeClass("activecont")
$("#four-cont").removeClass("activecont")
event.preventDefault();
});
$('#cont-three').on('click', function(event) {
$("#one-cont").removeClass("activecont")
$("#two-cont").removeClass("activecont")
$("#three-cont").addClass("activecont")
$("#four-cont").removeClass("activecont")
event.preventDefault();
});
$('#cont-four').on('click', function(event) {
$("#one-cont").removeClass("activecont")
$("#two-cont").removeClass("activecont")
$("#three-cont").removeClass("activecont")
$("#four-cont").addClass("activecont")
event.preventDefault();
});
});
Answer the question
In order to leave comments, you need to log in
Another question about tabs... well... already the seventh one in a week.
When the graduates already stand behind the machine, they ate all the baldness)))
here www.jooom.ru/toster/toster_10.html
or here www.jooom.ru/toster/toster_6.html
[
$("#one-cont"),
$("#two-cont"),
$("#three-cont"),
$("#four-cont"),
]
.forEach((target, i, tabs) => target.on(
'click',
(event) => {
tabs.forEach(tab => tab.removeClass("activecont"));
target.addClass("activecont");
event.preventDefault();
},
));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question