Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.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_Twitter Bootstrap - Fatal编程技术网

Javascript 引导表筛选器控制如何在搜索使用后清除输入框

Javascript 引导表筛选器控制如何在搜索使用后清除输入框,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,.clear()函数不适用于我的代码。我不知道如何操作jQuery中的标记 活动: function (){ var $table = $('#table') if($(".filter-control").is(":visible")){ $(".filter-control").hide() $table.bootstrapTable('refre

.clear()
函数不适用于我的代码。我不知道如何操作jQuery中的标记

活动:

         
function (){        
    var $table = $('#table')
    if($(".filter-control").is(":visible")){
         $(".filter-control").hide()
        $table.bootstrapTable('refresh')
        $(".filter-control").clear();
    } else {
        $(".filter-control").show()
        $table.bootstrapTable('refresh')
        $(".filter-control").clear();
    }       
}


有趣的Html代码是



  <table>
  <body>
    <table id="table">
    <thead>
      <tr>
        <th data-field="id"   data-filter-control="input"  data-width ="400"  >Id</th>
        <th data-field="name" data-filter-control="input"   data-width ="400"  >Item Name</th>
        <th data-field="price"data-filter-control="input"  data-width ="400"  >Item Price</th>
      </tr>
    </thead>
  </table>

  <script>
    function buttons(){
      return {
        btnUsersAdd: {
          text: 'Enable/Disable Filters',
          
          icon:'fa-filter',
          event: function (){
            
            if($(".filter-control").is(":visible")){
                $(".filter-control").hide()
                $(".filter-control").clear(); 
                $table.bootstrapTable('refresh')
            } else {
        $(".filter-control").show()
        $(".filter-control").clear();
        $table.bootstrapTable('refresh')            
             }
          }
        }
      }
    }
   
  </script>
  

身份证件
项目名称
项目价格
功能按钮(){
返回{
btnUsersAdd:{
文本:“启用/禁用筛选器”,
图标:'fa-filter',
事件:函数(){
如果($(“.filter control”).是(“:可见”)){
$(“.filter控件”).hide()
$(“.filter控件”).clear();
$table.bootstrapTable('refresh')
}否则{
$(“.filter控件”).show()
$(“.filter控件”).clear();
$table.bootstrapTable('refresh')
}
}
}
}
}

我找到了自己问题的答案, 1.将属性数据show filter control switch=“true”添加到表中
2.请确保没有数据高度属性,因为表的高度会发生变化,这将阻止这种变化。

您可能需要
$(“.filter control”).val(“”)
请详细说明我使用了$(“.filter control”).val(“”)。检查控制台,您应该会得到错误
$(…)。clear不是一个函数
所以change
。clear()
.val(“”)
-但是如果html没有准确显示
.filter control
是什么,这只是一个猜测。哦,我会这样做,我将整个html代码粘贴到这里。请正确设置您的问题的格式。您可以像这样使用倒勾“
”突出显示其他文本中的代码元素。
-代码块应该以三个倒勾开始和结束我已经修复了你的代码三次了,但是你一直把它放回不可读的状态。