I've written a script that searches for a string on a page and scrolls to it. I'd like for it to highlight the instances of the string on the page as well but that part of the script isn't working.
Here's my code:
$("#search").click(function(){
var thing = $("input#searchItem").val();
$(window).scrollTop($(".content:contains('" + thing + "'):first").offset().top -83);
$('.content').each(function(index, element) {
$(this).find(thing).each(function(i) {
this.html('<i class="found">' + thing + '</i>');
});
});
});