Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用jQuery或JavaScript过滤超出范围的结果_Javascript_Jquery_Html_Input - Fatal编程技术网

如何使用jQuery或JavaScript过滤超出范围的结果

如何使用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">

我需要创建一个函数,当.plot price大于sliderValue中的值时,该函数隐藏以下代码块

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();
}