简体   繁体   中英

Change text on div if class active

Welcome. At the beginning I want tell us, that my english is poor :-) So I have a problem with creating my website support on wordpress. My theme is fullpane where is section

<section id="homepage" class="clearfix section-post section-category-136 section-category-home-page default fullwidth post-16824 section type-section status-publish hentry ***active*** fullpage-active" data-anchor="homepage" style="height: 979px; padding: 0px 0px 70px; line-height: 894px;">

Like we can see name 'active' is generated automatically and I think that I can use it to my problem.

I want create some like index '1 for 5 section' on the right side window with fixed position and when I scroll to bottom number should change number '2 for 5 section' So I create jquery

<script type="text/javascript">
    $( document ).ready(function() {
        if($( "#homepage" ).hasClass( "active" )){
            $("div#date").text("2 for 5");
        }
    });
</script>

And not working properly. This page is located adress emotivo.pl/nowe

If I forgot tell us for something important tell me about it.

UPDATE

Modify your script to this:

<script>
$(window).scroll(function(){
    var children = $("#superContainer").children(); 
    $(children).each(function(index,value) {
    if($(value).hasClass("active"))
        $("div#date").html(index+" of "+ children.length);
  });
});
</script>

This may not exactly work by copy pasting given your website is overriding scroll function, but the core logic is same.

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