簡體   English   中英

搜索過濾器引導卡未顯示特定圖像

[英]Search filter bootstrap card didn't show the specific image

當我搜索圖像的特定名稱時。 行名稱的 rest 仍在顯示,但我只想查看搜索中的數據。 見下圖

顯示:Select 數據庫中的所有數據。

 <?php$checkQuery = "SELECT `h_business_logo`,`h_business_name`,`h_business_desc` FROM user_bsns WHERE h_isActive = 1  ORDER BY h_business_name DESC";
                        $checkResult = mysqli_query($db->conn, "$checkQuery")
                    ?>

卡:此卡有一個 animation

 <div class="card-body col-lg-12" >
                          <div class="card-body col-lg-12">
                          <input class="form-control" id="myInput" type="text" placeholder="Search.." style="float:left; width:25%;">
                          <button class="btn" style="margin-left: 5px;background-color: #e72329;color: white;"> Search </button>
                          </div>
                          <?php
                          if(mysqli_num_rows($checkResult) > 0):{
                          }
                            while($row = mysqli_fetch_array($checkResult)){
                              ?>
                    
                          <div class="panel" id="myDIV">
                                        <div class="holder flipH" >
                                            <div class="card shadow-none">
                                                 <div class="col-sm-0 column <?=$row['h_business_name'];?>"   >
                                                   
                                                           <div class="front"style="float:left;  >  
                                                           <img src="<?=$row['h_business_logo']; ?> " 
                                                           style="height:150px; width:155px; border-radius: 50%; ">
                                                           </div>
                                                      
                                                  </div>  
                                                 <span style= "text-align:center;">
                                                        <h5><?=$row['h_business_name'];?></h5>
                                                 </span>  
                                         <span style="text-align:center;">
                                              <p><?=$row['h_business_desc'];?></p>
                                          </span>
                                       </div>
                              </div>
                            </div>

                              <?php
                            }
                          endif;
                          ?>
                        </div>
                       
                        <!-- /.card-body -->
                </div>

而這個就是搜索過濾器的function。

<script>
$(document).ready(function(){
  $(".btn").on("click", function() {
    var value = $("#myInput").val();
    lastval = "col-sm-5 column "+value;
    x = document.getElementsByClassName("column");
    $("#myDIV div").filter(function() {
      for (i = 0; i < x.length; i++) {
        element = x[i];
        if (element.className.indexOf(value) == -1){
          element.classList.add("nonshow");
          element.classList.remove("show");
        }
        else {
          element.classList.add("show");
          element.classList.remove("nonshow");
        }
      }
    });
  });
});
</script>

請幫助我改進代碼。

在此處輸入圖像描述

更新:我使用這個腳本(jquery)解決了我的問題更新:我使用這個腳本來自動搜索。

$(document).ready(function(){
  $("#myInput").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#myDiv ").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
    });
  });
}); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM