简体   繁体   中英

Scrollto no working in Chrome & Opera

In chrome & opera no working function scrollto. In firefox working. I don't know in what a problem. Thanks for help.

function scroll_to_word(){
 var pos = $('.content .selectHighlight').position();
 $.scrollTo(".selectHighlight", 500, {offset:-50});
 }

$('#search_text').bind('keyup oncnange', function() {
 $('.content').removeHighlight();
 txt = $('#search_text').val();
 if (txt == '') return;
 $('.content').highlight(txt);
 search_count = $('.content span.highlight').size() - 1;
 count_text = search_count + 1;
 search_number = 0;
 $('.content').selectHighlight(search_number);
 if ( search_count >= 0 ) scroll_to_word();
 $('#count').html('Найдено: <b>'+count_text+'</b>');
 });

$('#clear_button').click(function() {
 $('.content').removeHighlight();
 $('#search_text').val('поиск по странице');
 $('#count').html('');
 });

You have a typo here:

keyup oncnange

should be:

keyup onchange

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM