When I click on a class called "vis", things start to appear and other items disappear. When clicked on that item, it removes all classes with the name "vis", only the item that has been clicked gets a new class called "clickyEvent". Thing is, when I click on an invisible item which it's class has been removed ("vis"), the click event still works and makes it visible, which causes bugs. (causes loads of bugs, so I've put those things in comments)
What I want is that when I click on the circle (vis), the other items dissapear (works) and when I click on an invisible item, that nothing happens.
When I click on the back button, everything goes back to the state it was. Another thing I want, is when I click again on the item that I've clicked on (the one that doesn't dissapear) it also goes back to normal state (same event as the back button). (DOESN'T WORK)
This is my HTML
<section class="pakketten">
<header>
<h1>Pakketten</h1>
</header>
<button class="back">back</button>
<div class="pakket">
<div class="vis">
<div class="circle">
<img src="_img/jets.png" width="71" height="107" alt="jets" name="jets">
</div>
</div>
<div class="invis-wrapper">
<div class="invis">
<h2>Jets</h2>
<p>Een « jet pack », deze jets kun je aansluiten op jouw voertuig. Door de kleine boost spring je als ware in de lucht voor een korte tijd en kun je langs een heleboel obstakels geraken, ook kan het gebruikt worden om coole tricks uit te voeren.</p>
</div>
</div>
</div>
<div class="pakket">
<div class="vis">
<div class="circle">
<img src="_img/rockets.png" width="93" height="122" alt="rockets" name="rockets">
</div>
</div>
<div class="invis-wrapper">
<div class="invis">
<h2>Jets</h2>
<p>Een « jet pack », deze jets kun je aansluiten op jouw voertuig. Door de kleine boost spring je als ware in de lucht voor een korte tijd en kun je langs een heleboel obstakels geraken, ook kan het gebruikt worden om coole tricks uit te voeren.</p>
</div>
</div>
</div>
<div class="pakket">
<div class="vis">
<div class="circle">
<img src="_img/jets.png" width="71" height="107" alt="jets" name="jets">
</div>
</div>
<div class="invis-wrapper">
<div class="invis">
<h2>Jets</h2>
<p>Een « jet pack », deze jets kun je aansluiten op jouw voertuig. Door de kleine boost spring je als ware in de lucht voor een korte tijd en kun je langs een heleboel obstakels geraken, ook kan het gebruikt worden om coole tricks uit te voeren.</p>
</div>
</div>
</div>
<div class="pakket">
<div class="vis">
<div class="circle">
<img src="_img/bal.png" width="94" height="96" alt="bal" name="bal">
</div>
</div>
<div class="invis-wrapper">
<div class="invis">
<h2>Jets</h2>
<p>Een « jet pack », deze jets kun je aansluiten op jouw voertuig. Door de kleine boost spring je als ware in de lucht voor een korte tijd en kun je langs een heleboel obstakels geraken, ook kan het gebruikt worden om coole tricks uit te voeren.</p>
</div>
</div>
</div>
<div class="pakket">
<div class="vis">
<div class="circle">
<img src="_img/jets.png" width="71" height="107" alt="jets" name="jets">
</div>
</div>
<div class="invis-wrapper">
<div class="invis">
<h2>Jets</h2>
<p>Een « jet pack », deze jets kun je aansluiten op jouw voertuig. Door de kleine boost spring je als ware in de lucht voor een korte tijd en kun je langs een heleboel obstakels geraken, ook kan het gebruikt worden om coole tricks uit te voeren.</p>
</div>
</div>
</div>
</section>
This is my js
$(".vis").click(function () {
$(this).siblings(".invis-wrapper").css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 800);
$(this).siblings(".invis-wrapper").addClass("clicked");
// $(this).addClass("clickyEvent");
$(".vis").not(this).addClass("invisfade");
$('.invisfade').css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 800);
// $("div").removeClass("vis");
});
$(".clickyEvent").click(function() {
removeStuff();
console.log("ok");
});
$(".back").click(function() {
// $(".invis-wrapper:visible").fadeToggle(1000);
removeStuff();
});
}
function removeStuff() {
$('.invisfade').css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 800);
$(".clicked").css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 800);
$(".clicked").removeAttr("style");
// $(".clicked").addClass("vis");
// $(".invisfade").addClass("vis");
$("div").removeClass("clicked");
$("div").removeClass("invisfade");
}