i trying page scroll specific div element when typing text input. nav has fixed position , item.offset().top output 2859, page not scroll. here code:
$('nav').on('keyup, keydown','input[name=search]',function(){ var search = $('input[name=search]').val(), name = '', item = '', searchoff = false, len = search.length; if(len>2){ $('.products li').each(function(){ item = $(this); name = item.find('p.left').text().substring(0,len).tolowercase(); if (name==search && searchoff==false){ console.log(item.offset().top); $('body, html').animate({scrolltop:item.offset().top},'slow'); searchoff=true; } }); } });
any ideas?
Comments
Post a Comment