Hi all. I've been long looking into a solution to my jQuery/JS code, but to no avail. I want to be able to scroll to the searched term when I type it in. It will do this now, but then if I search for a word that's at the top, I don't have anything for it to scroll up to it. Here is my code:
$(function(){
$('.searchTerm').bind('keyup change',function(ev){// pull in the new valuevar searchTerm = $(this).val();// remove any old highlighted terms
$('body').removeHighlight();// disable highlighting if emptyif( searchTerm ){// highlight the new term
$('body').highlight( searchTerm );
$('html, body').delay(1500).animate({
scrollTop: $('#results').offset().top
},475);}});});
Is there something missing, or am I using the wrong code? I don't know what to do.
scroll up and down to find search terms
in Beginners Web Design
Posted
Hi all. I've been long looking into a solution to my jQuery/JS code, but to no avail. I want to be able to scroll to the searched term when I type it in. It will do this now, but then if I search for a word that's at the top, I don't have anything for it to scroll up to it. Here is my code:
Is there something missing, or am I using the wrong code? I don't know what to do.