Hello, I’ll show you how easy it is to highlight a word in a search using coffeescript, and then I will show the difference in the coffee and use jquery normal, and in the end, the result compiled coffeescript.
The code is much more organized and beautiful.
To call the function Search do as follows:
any_name = new Search();
any_name=highlight(“your param or quote”);
in Rails: any_name=highlight(“<%= params[:search] %>”);
in PHP: any_name=highlight(“<?php echo $_POST["search"]?>”); OR any_name=highlight(“<?php echo $_GET["search"]?>”);
Using CoffeeScript.
Using jQuery
Result Compiled of CoffeeScript
CoffeeScript code download here.




