Showing posts with label Jquery. Show all posts
Showing posts with label Jquery. Show all posts

How to Filter Table using Jquery

agyanadda

You can create filter table in bootstrap using Jquery

<!--DOCTYPE html--> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> </head> <body> <br><br> <div class="container"> <div class="panel panel-default"> <div class="panel-heading">Filter Tables</div> <div class="panel-body"> <!--========================--> <input class="form-control" id="myInput" type="text" placeholder="Search.."> <br> <table class="table table-bordered table-striped"> <thead> <tr> <th>SR NO</th> <th>EMPLOYEE NAME</th> <th>ADDRESS</th> <th>EMAIL ID</th> </tr> </thead> <tbody id="myTable"> <tr> <td>101</td> <td>Praveen</td> <td>Noida</td> <td>praveen@example.com</td> </tr> <tr> <td>102</td> <td>Nandan</td> <td>Delhi</td> <td>sam@mail.com</td> </tr> <tr> <td>103</td> <td>Deepti</td> <td>Goa</td> <td>deepti@greatstuff.com</td> </tr> <tr> <td>104</td> <td>Mohan</td> <td>Delhi</td> <td>mohan@test.com</td> </tr> </tbody> </table> <!--=======================--> </div> </div> </div> <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> </body> </html>

Click button copy to clipboard using jQuery

agyanadda
<!--DOCTYPE html--> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> function copyToClipboard(element) { var $temp = $("<input>"); $("body").append($temp); $temp.val($(element).text()).select(); document.execCommand("copy"); $temp.remove(); } </script> </head> <body> <br><br> <pre id="copyy">Thanku for copy me </pre> <button onclick="copyToClipboard('#copyy')">Click to copy ME</button> <br/><br/><input type="text" placeholder="Paste here for test" /> </body> </html>