I have a static site and I was wondering if it is possible to have a search form on the website and then use JavaScript of jQuery to search the page for certain keywords and then use jQuery to add a class or something.
use the JQuery "Contains" Selector
Then use the addClass() method to assign your class
http://api.jquery.com/addClass/
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn</div>
<script>
$("div:contains('John')").css("text-decoration", "underline");
</script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With