I'm try to build a little filter based on the ranking ( numeric value stored in a string ) , but I'm stuck with a part of the code.
Expected behaviour
When a User click on the select
option the elements that doesn't match the value selected have to hide(not remove).
$(".notSearched").hide();
$("select").on("click", function() {
let selectedValue = this.value;
$('.card-wrap').each(function(selectedValue) {
console.log("sei qua");
if (selectedValue === "0") {
return
}
let rate = $(".restoName").find(".ratePlace").text();
let numRate = parseInt(rate);
if (rate !== selectedValue || rate !== (selectedValue + 0.5)) {
$(this).addClass("notSearched");
}
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="columnsContainer">
<div class="leftColumn">
<div class="filterResearch">
<select name="filter" id="searchFilter">
<option value="all">Apply a filter</option>
<option value="1">1 Star</option>
<option value="2">2 Stars</option>
<option value="3">3 Stars</option>
<option value="4">4 Stars</option>
<option value="5">5 Stars</option>
</select>
</div>
<div id="map"></div>
<div class="rightColumn" style="margin-top:50px;">
//Cards down below
<div class="card-grid">
<div class="card-wrap" id="">
<img src="https://image.ibb.co/k4SSPK/Spinaci_Green_Dark_Blue.jpg " class="photo">
<div class="restoName">
<h3>Restaurant Name Here</h3>
<p class="restoAddress">In questo posto ci andrà l'indirizzo del ristorante in questione, sarà una stringa lunga</p>
<p class="ratePlace">Rating: 4,5</p>
</div>
</div>
<div class="card-wrap" id=""><img src=" https://image.ibb.co/k4SSPK/Spinaci_Green_Dark_Blue.jpg" class="photo">
<div class="restoName">
<h3>Restaurant Name Here2</h3>
<p class="restoAddress">In questo posto ci andrà l'indirizzo del ristorante in questione, sarà una stringa lunga222</p>
<p class="ratePlace">Rating: 4,52</p>
</div>
</div>
<div class="card-wrap" id=""><img src=" https://image.ibb.co/k4SSPK/Spinaci_Green_Dark_Blue.jpg" class="photo">
<div class="restoName">
<h3>Restaurant Name Here3</h3>
<p class="restoAddress">In questo posto ci andrà l'indirizzo del ristorante in questione, sarà una stringa lunga333</p>
<p class="ratePlace">Rating: 4,53</p>
</div>
</div>
</div>
</div>
</div>
</div>
I have no errore in the console. Before the downvotes, I searched all the evening how to do, I will link here some links about it.