如何使用jQuery或JavaScript过滤超出范围的结果
我需要创建一个函数,当.plot price大于sliderValue中的值时,该函数隐藏以下代码块如何使用jQuery或JavaScript过滤超出范围的结果,javascript,jquery,html,input,Javascript,Jquery,Html,Input,我需要创建一个函数,当.plot price大于sliderValue中的值时,该函数隐藏以下代码块 function updateTextInput(val) { document.getElementById('textInput').value=val; } 提前感谢您的帮助,并对第一次出现的任何格式/问题错误表示歉意向您的区块添加id <div class="plot-item col-xs-12 four"> <div class="plot-img">
function updateTextInput(val) {
document.getElementById('textInput').value=val;
}
提前感谢您的帮助,并对第一次出现的任何格式/问题错误表示歉意向您的区块添加id
<div class="plot-item col-xs-12 four">
<div class="plot-img">
<img src="img/mobile/overview-img.jpg" class="img-border img-responsive">
</div>
<div class="plot-details">
<h2 class="plot-location">Cornwall</h2>
<p class="plot-number">Plot 5</p>
<ul>
<li class="bedrooms">4 bedrooms</li>
<li class="plot-price">255995</li>
<li class="plot-view"><a href="plot-page.html"> View Plot</a></li>
</ul>
<p class="plot-status">Sold</p>
</div>
</div>
此外,不应使用onchange属性。拆分你的源代码!
HTML:
Javascript:
<input type="range" name="rangeInput" id="myInputRange" min="100000" max="750000">
<input type="text" id="textInput" value="">
<div class="plot-item col-xs-12 four">
<!-- Other code -->
</div>
我想你要找的是一个过滤页面,如果是的话,试试看
$('#myInputRange').change(function() {
value = $(this).val();
$('#textInput').val(value);
if(value < $('.plot-price').val())
{
$('#yourid').fadeOut();
}
else
{
$('#yourid').fadeIn();
}
}
演示:感谢您的帮助,这已经解决了问题!
function updateTextInput(val) {
$('#textInput').val(val);
if(val < $('.plot-price').val())
{
$('#yourid').fadeOut();
}
}
<input type="range" name="rangeInput" id="myInputRange" min="100000" max="750000">
<input type="text" id="textInput" value="">
<div class="plot-item col-xs-12 four">
<!-- Other code -->
</div>
$('#myInputRange').change(function() {
value = $(this).val();
$('#textInput').val(value);
if(value < $('.plot-price').val())
{
$('#yourid').fadeOut();
}
else
{
$('#yourid').fadeIn();
}
}
function updateTextInput(val) {
$('#textInput').val(val);
$('.plot-item').hide().filter(function () {
return val >= +$(this).find('.plot-price').text()
}).show();
}