Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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
Javascript 重置下拉选择后重置列表_Javascript_Jquery - Fatal编程技术网

Javascript 重置下拉选择后重置列表

Javascript 重置下拉选择后重置列表,javascript,jquery,Javascript,Jquery,我已经列了一张单子。我添加了一些下拉列表来对列表进行排序。一旦它排序,我想能够重置下拉列表回到没有。(已经完成了)。但列表不会更新回,就好像没有选择任何内容一样。我该怎么做 我用来操作列表的代码: <script> $.noConflict(); jQuery( document ).ready(function( $ ) { $('.container').on("change", 'select', function() { var type = $

我已经列了一张单子。我添加了一些下拉列表来对列表进行排序。一旦它排序,我想能够重置下拉列表回到没有。(已经完成了)。但列表不会更新回,就好像没有选择任何内容一样。我该怎么做

我用来操作列表的代码:

<script>
$.noConflict();
jQuery( document ).ready(function( $ ) {   
$('.container').on("change", 'select', function() {
  var type = $('#BBFHtype').val().toLowerCase(),
    surface = $('#BBFHsurface').val().toLowerCase(),
    sticking = $('#BBFHsticking').val().toLowerCase(),
    panel = $('#BBFHpanel').val().toLowerCase(),
    height = $('#BBFHheight').val().toLowerCase(),
    thickness = $('#BBFHthickness').val().toLowerCase();

  var table = $("#BBFHDoors");
  var trs = table.find('tr');
  trs.hide();    
  var filtered = trs.filter(function(index, elem) {
    var tds = $(elem).find('td');
    if (type !== "all" && tds.eq(1).text().trim().toLowerCase() !== type) {return false;}
    if (surface !== "all" && tds.eq(2).text().trim().toLowerCase() !== surface) {return false;}
    if (sticking !== "all" && tds.eq(3).text().trim().toLowerCase() !== sticking) {return false;}
    if (panel !== "all" && tds.eq(4).text().trim().toLowerCase() !== panel) {return false;}
    if (height !== "all" && tds.eq(5).text().trim().toLowerCase() !== height) {return false;}
    if (thickness !== "all" && tds.eq(6).text().trim().toLowerCase() !== thickness) {return false;}
    return true;
  })

  filtered.show();

  if (filtered.length == 0) {
    alert("No Records Found!!!");
  }
});   
});
</script>
$(function () {$("#btnReset").bind("click", function () 
{$("#BBFHtype")[0].selectedIndex = 0; 
 $("#BBFHsurface")[0].selectedIndex = 0;
 $("#BBFHsticking")[0].selectedIndex = 0;
 $("#BBFHpanel")[0].selectedIndex = 0;
 $("#BBFHheight")[0].selectedIndex = 0;
 $("#BBFHthickness")[0].selectedIndex = 0;
});});   
我尝试过使用.prop和.attr(已选)并删除它()。但是没有成功。例如:
$(“#BBFHtype”)[0]。属性(“已选择”,true)


任何帮助都会很棒

只需在
选择
元素上触发更改:

$('select').trigger('change');
完整功能:

$(function () {$("#btnReset").bind("click", function () 
{$("#BBFHtype")[0].selectedIndex = 0; 
 $("#BBFHsurface")[0].selectedIndex = 0;
 $("#BBFHsticking")[0].selectedIndex = 0;
 $("#BBFHpanel")[0].selectedIndex = 0;
 $("#BBFHheight")[0].selectedIndex = 0;
 $("#BBFHthickness")[0].selectedIndex = 0;

 $('select').trigger('change');
});});  

另外,请参阅完整的工作演示

了解一个开始,您使用的是
noConflict
,它将
$
作为
jQuery
的一个值取消设置。因此,您应该在代码中的任何地方(包括
noConflict
行本身)只使用
jQuery
$
将不起作用。您可以共享您的下拉式html吗?@asaf在此处查看:我发现了您的问题,请参阅下面的答案有些,可以。这是多么简单,让我觉得很傻。