jQuery Mobile - 將任何東西篩選出來



描述

篩選小工具還可以用於篩選包含其他元素的任何元素,例如,包含 <p><div> 元素。

示例

下面的示例演示了在 jQuery Mobile 中使用 篩選任何內容

<!DOCTYPE html>
<html>
   <head>
      <title>Filterable Anything</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>

   <body>
      <form>
         <input data-type = "search" id = "divOfPs-input">
      </form>
      
      <div class = "elements" data-filter = "true" data-input = "#divOfPs-input">
         <p><strong>Paragraph one</strong> Lorem ipsum dolor sit amet, 
         consectetur adipiscing elit</p>
         
         <p><strong>Paragraph two</strong> sed do eiusmod tempor incididunt 
         ut labore et dolore magna aliqua</p>
         
         <p><strong>Paragraph three</strong> quis nostrud exercitation ullamco 
         laboris nisi ut aliquip ex ea commodo consequa </p>
         
         <p><strong>Paragraph four</strong>  Duis aute irure dolor in reprehenderit 
         in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>
         
         <p><strong>Paragraph five</strong>  Excepteur sint occaecat cupidatat non 
         proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
      </div>
      
   </body>
</html>

輸出

讓我們執行以下步驟,瞭解上述程式碼是如何工作的:

  • 將上述 html 程式碼作為 filterable_anything.html 檔案儲存在您的伺服器根資料夾中。

  • 將此 HTML 檔案作為 https:///filterable_anything.html 開啟,您便會看到以下輸出。

jquery_mobile_widgets.htm
廣告
© . All rights reserved.