Ich verwende Radioknöpfe wie eine Seitennummerierung für mein Karussell, was gut funktioniert. Wenn ich die Folie mithilfe der Karusselltasten anstelle der Optionsfelder ändere, ändert sich der Status der Optionsfelder nicht, sodass die ausgewählte Schaltfläche nicht mit der ausgewählten Folie übereinstimmt. Wie kann ich das beheben?Wie kann ich den Status der Optionsschaltflächen aktualisieren, damit sie dem Karussellstatus entsprechen?
HTML:
<div class="container">
<div id="carousel" class="carousel slide" data-interval="false" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive center-block" src="http://www.w3schools.com/bootstrap/img_chania.jpg">
</div>
<div class="item">
<img class="img-responsive center-block" src="http://www.w3schools.com/bootstrap/img_chania2.jpg">
</div>
<div class="item">
<img class="img-responsive center-block" src="http://www.w3schools.com/bootstrap/img_flower.jpg">
</div>
<div class="item">
<img class="img-responsive center-block" src="http://www.w3schools.com/bootstrap/img_flower2.jpg">
</div>
</div>
<a class="left carousel-control" href="#carousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<br>
<center>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active s1"><input type="radio" name="options" autocomplete="off" checked>1</label>
<label class="btn btn-primary s2"><input type="radio" name="options" autocomplete="off">2</label>
<label class="btn btn-primary s3"><input type="radio" name="options" autocomplete="off">3</label>
<label class="btn btn-primary s4"><input type="radio" name="options" autocomplete="off">4</label>
</div>
</center>
JS:
$(function() {
$(".s1").click(function() {$("#carousel").carousel(0);});
$(".s2").click(function() {$("#carousel").carousel(1);});
$(".s3").click(function() {$("#carousel").carousel(2);});
$(".s4").click(function() {$("#carousel").carousel(3);});
});
Bitte nicht hinzufügen " [Gelöst] "oder ähnlich Ihrem Titel. Stattdessen [bitte die Antwort akzeptieren] (// stackoverflow.com/help/accepted-answer), die Ihnen am meisten geholfen hat (auch wenn es [Ihre eigene Antwort] ist (// stackoverflow.com/help/self-answer)) und wenn Sie genug [Reputation] (// stackoverflow.com/help/whats-reputation), [upvote] (// stackoverflow.com/privileges/vote-up) haben, haben Sie alle Antworten, die Ihnen geholfen haben. –