記得之前寫過一個預約表格~~~~~比這個更難,一大串前端js~~~忘了~~~好記性不如爛筆頭~~記錄下,既幫助別人,也幫助本身~~~前端
實現思路~經過.on監聽input標籤的內容變化,經過this獲取到val,經過.hide隱藏未匹配標籤~~~大體這樣jquery
<input type="text" class="form-control" id="item_keyword" name="item_keyword" placeholder="請輸入關鍵字查找">
<script src="/static/js/jquery-3.1.1.min.js"></script> <script > /* 實時搜索框,及點擊按鈕全選\取消*/ $('#item_keyword').on('input propertychange', function() { console.log( $(this).val()); $('table tbody tr').hide() .filter(":contains('" + ($(this).val()) + "')") .show(); }); </script>