<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { //$('[data-slide="0"]').addClass('demo'); $("#mytxt").on("blur", function(){ $("p").each(function(){ alert($(this).html().toLowerCase().indexOf($("#mytxt").val())); if($(this).html().toLowerCase().indexOf($("#mytxt").val())>=0) { $(this).addClass('show'); } else { $(this).addClass('hide'); } }); }); }); </script> <style> .demo { font-size: 150%; color: red; } .hide { display: none; } .show { display: block; } </style> </head> <body> <input type="textbox" id="mytxt"> <p data-slide="0">Rocky</p> <p data-slide="1">Amit</p> <p data-slide="2">John</p> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more