فیلتر جدول ها
بازگشت به صفحه اصلی
بازگشت به صفحه مقاله
دو ستونی
دو سطری
اجرای کد RUN »
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#myInput").on("keyup", function() { var value = $(this).val().toLowerCase(); $("#myTable tr").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) }); }); }); </script> <style> table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; } tr:nth-child(even) { background-color: #dddddd; } </style> </head> <body> <h2>Filterable Table</h2> <p>Type something in the input field to search the table for first names, last names or emails:</p> <input id="myInput" type="text" placeholder="Search.."> <br><br> <table dir="rtl"> <thead> <tr> <th>نام</th> <th>نام خانوادگی</th> <th>ایمیل</th> </tr> </thead> <tbody id="myTable"> <tr> <td>فامیل</td> <td>دور</td> <td>famil@example.com</td> </tr> <tr> <td>خرضو خان</td> <td>بالا برره</td> <td>khorzoo@mail.com</td> </tr> <tr> <td>دهقان</td> <td>فداکار</td> <td>dehghan@greatstuff.com</td> </tr> <tr> <td>چوپان</td> <td>دروغگو</td> <td>choopan@test.com</td> </tr> </tbody> </table> <p>شروع کردیم تا از فیلتر شدن عناوین ستون ها جلوگیری کنیم tbody توجه داشته باشید که فیلتر را از .</p> </body> </html>