Ich stieß auf ein Problem mit meiner .click jquery Funktion. Was ich will: Wenn ich den Knopf drücke, sollte ein div angezeigt werden: keiner, und ein anderer soll anzeigen: block. Dies funktioniert beim ersten Drücken des Knopfes, aber danach passiert nichts. Hier.click jquery Funktion funktioniert nicht mehr nach einer Verwendung
ist ein Code:
$(document).ready(function(){
$("#0").click(function(){
$("#product_container2").css("display", "none");
$("#product_container3").css("display", "none");
$("#product_container1").css("display", "block");
});
$("#1").click(function() {
$("#product_container1").css("display", "none");
$("#product_container3").css("display", "none");
$("#product_container2").css("display", "block");
});
$("#2").click(function(){
$("#product_container1").css("display", "none");
$("#product_container2").css("display", "none");
$("#product_container3").css("display", "block");
});
});
<section id="product_container1" class="col-12 product_container">
\t <h1 id="product-h1"> Produkter </h1>
\t <hr style="width:90%; margin-left:5%">
\t <div class="product_info_container productx">
\t \t <img src="bilder/dumleOriginal220.png" alt="Dumle" id="product1" class="product"></img>
\t \t <h2> Dumle Original 220 g</h2>
\t \t \t <p> Dumle brings out the twinkle in your eyes. The goofy sweet is a combination of soft chewy toffee and smooth Fazer Chocolate. The... </p>
\t \t \t
\t \t <div id="button"> <b> Visa produkt information </b> </div>
\t <hr style="width:80%; margin-left:5%; margin-top:10px;">
\t </div>
<div id="buttons">
<a href="#product_container1" id="0" class="mybutton myred">1</a>
<a href="#product_container2" id="1" class="mybutton myblue">2</a>
<a href="#" id="2" class="mybutton myblue">3</a>
</div>
</section>
<section id="product_container2" class="col-12 product_container">
\t <h1 id="product-h1"> Produkter </h1>
\t <hr style="width:90%; margin-left:5%">
\t <div class="product_info_container productx">
\t \t <img src="bilder/dumleOriginal220.png" alt="Dumle" id="product1" class="product"></img>
\t \t <h2> Dumle Original 220 g</h2>
\t \t \t <p> Dumle brings out the twinkle in your eyes. The goofy sweet is a combination of soft chewy toffee and smooth Fazer Chocolate. The... </p>
\t \t \t
\t \t <div id="button"> <b> Visa produkt information </b> </div>
\t <hr style="width:80%; margin-left:5%; margin-top:10px;">
\t </div>
<div id="buttons">
<a href="#product_container1" id="0" class="mybutton myred">1</a>
<a href="#product_container2" id="1" class="mybutton myblue">2</a>
<a href="#" id="2" class="mybutton myblue">3</a>
</div>
</section>
<section id="product_container3" class="col-12 product_container">
\t <h1 id="product-h1"> Produkter </h1>
\t <hr style="width:90%; margin-left:5%">
\t <div class="product_info_container productx">
\t \t <img src="bilder/dumleOriginal220.png" alt="Dumle" id="product1" class="product"></img>
\t \t <h2> Dumle Original 220 g</h2>
\t \t \t <p> Dumle brings out the twinkle in your eyes. The goofy sweet is a combination of soft chewy toffee and smooth Fazer Chocolate. The... </p>
\t \t \t
\t \t <div id="button"> <b> Visa produkt information </b> </div>
\t <hr style="width:80%; margin-left:5%; margin-top:10px;">
\t </div>
<div id="buttons">
<a href="#product_container1" id="0" class="mybutton myred">1</a>
<a href="#product_container2" id="1" class="mybutton myblue">2</a>
<a href="#" id="2" class="mybutton myblue">3</a>
</div>
</section>
Vielen Dank im Voraus!
Oh gut konfrontiert wird. Die IDs wurden in Klasse geändert und das Problem wurde behoben. Das war etwas, das ich irgendwann reparieren würde, wusste nicht, dass es so Probleme verursachen könnte. Danke für deine Hilfe, werde mich daran für zukünftige Dinge erinnern;) – beckman
Ehrfürchtig, ich könnte dir helfen! –