Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
jqueryで同じクラスの次の位置を取得する方法,
このコードを試していますが、次のクリックで機能しません
var directiveScrollTop= $(".site_section").next().position().top;
いくつかの要素に取り組んでいて、 class で次の要素を見つける必要がある場合site_section:
site_section
$(this).nextAll(".site_section")
したがって、コードは次のようになります。
var directiveScrollTop= $(this).nextAll(".site_section").position().top;
ただし、それらは DOM で同じ深さにある必要があります。