I am currently working on a rating application where only the selected circle should remain green, not all of them.
$('#rating-container').click(function () {
var element = $('#target');
var container = $('#rating-container');
var index = container.children().get(element);
var foundElement = container.children().get(index);
var jQueryObject = $(foundElement);
jQueryObject.addClass('rating-chosen');
});
This is the HTML structure:
<div id="rating-container">
<div class="rating-circle"></div>
<div class="rating-circle"></div>
<div id="target" class="rating-circle"></div>
<div class="rating-circle"></div>
<div class="rating-circle"></div>
</div>
You can view the Codepen demo at the following link: