EDIT: It seems like JQuery is hiding all elements on my page below the reviews after the toggling button is clicked. Any ideas to why this might be?
On my page, I have a bunch of buttons which correspond to an instructor. And I have reviews, which contain an instructor. By default, all reviews are shown. When one of the buttons is clicked, I want to show only the reviews for that instructor. And when it is clicked off, I want to show all the reviews again, or if another instructor button was pressed, I want to show the reviews for that.
HTML for Instructor Buttons
<button class="ui basic small button instructor-button" id="Instructor A">
Instructor A
</button>
<button class="ui basic small button instructor-button" id="Instructor B">
Instructor B
</button>
HTML for Reviews
<div class="reviews">
<div class="review" data-instructor="Instructor A">
// elements for review
</div>
<div class="review" data-instructor="Instructor B">
// elements for review
</div>
</div>
This is the JQuery that I've attempted
$('.instructor-button').click(function() {
var instructor = this.id;
$('.review[data-instructor!="' + instructor + '"]').toggle()
});
This works but only when the first review is the one I selected, otherwise it hides all the reviews. Any idea on how to go about doing this?