javascript - Jquery scroll to closest element with .class -


the problem

i have html page, using search engine "ctrl+f" created me, integrated jquery plugin highlights me result searched for, , adds class ".highlight" elements highlights, thing want scroll between them , each time press search button.

i tried didn't work:

 $(document).ready(function () {          $("#btnsearch").on("click", function () {             $('html, body').animate({                 'scrolltop': $(this).closest(".highlight").position().top             });         });     }); 

maybe helps you...

 $(document).ready(function () {      $("#btnsearch").on("click", function () {         $('html, body').animate({             'scrolltop': $(this).closest(".highlight").parent().scrolltop()+ $(this).closest(".highlight").offset().top - $(this).closest(".highlight").parent().offset().top,          });     }); }); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -