try this code..
function searchAndHighlight(searchTerm, selector) {
if(searchTerm) {
var selector = selector || "body";
var searchTermRegEx = new RegExp(searchTerm,"ig");
var matches = $(selector).text().match(searchTermRegEx);
if(matches) {
$('.highlighted').removeClass('highlighted');
$(selector).html($(selector).html()
.replace(searchTermRegEx, ""+searchTerm+""));
if($('.highlighted:first').length) {
$(window).scrollTop($('.highlighted:first').position().top);
}
return true;
}
}
return false;
}
$(document).ready(function() {
$('#search-button').on("click",function() {
if(!searchAndHighlight($('#search-term').val())) {
alert("No results found");
}
});
});