How to hide all sections with the containing span values exceeding/ not exceeding the current value of the range slider?
HTML Range Slider:
<span>Price from: </span><span id="price"></span><span> $</span>
<input type="range" min="0" max="1000" value="0" id="range"/>
HTML Sections: (examples)
<div id="main">
<section>
<div class="content">
<p>Current trade: <span id="data">41,99</span> $ on the market</p>
</div>
</section>
<section>
<div class="content">
<p>Current trade: <span id="data">362,37</span> $ on the market</p>
</div>
</section>
<section>
<div class="content">
<p>Current trade: <span id="data">789,64</span> $ on the market</p>
</div>
</section>
</div>
My attempt in jQuery so far:
Current value display in a span above the range slider: (working)
var slider = document.getElementById("range");
var rdata = document.getElementById("price");
rdata.innerHTML = slider.value;
slider.oninput = function() {
rdata.innerHTML = this.value;
}
Hide all sections with span values exceeding the current range slider value: (not working)
$(document).ready(function(){
var slider = document.getElementById("range");
var rdata = slider.value;
$("#main").find('#data').each(function () {
return parseInt($(this).text()) < rdata;
}).parent().parent().hide();
)}