Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Add Div Class to DIV ID

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #182495
    siouxfan45
    Participant

    I use the code below to add the div class .tiny to the div id #header-wrap and .tiny2 to #whole when a user scrolls down 5 pixels or more on a page. I swear this worked in the past, but no longer seems to work. (Running it here: http://themeforward.com/demo2/practice-areas/)

    My javascript skills are horrible, so maybe I just messed something up?

    `
    <script type=”text/javascript”>
    $(window).scroll(function() {
    var hi = $(document).scrollTop(); if (5 > $(document).scrollTop()) {
    $(‘#header-wrap’).removeClass(‘tiny’);
    } else { $(‘#header-wrap’).addClass(‘tiny’); }});

    $(window).scroll(function() {
    var hi = $(document).scrollTop(); if (5 > $(document).scrollTop()) {
    $(‘#whole’).removeClass(‘tiny2’);
    } else { $(‘#whole’).addClass(‘tiny2’); }});
    </script>
    `

    #182496
    Paulie_D
    Member

    I copied your JQ into Codepen and it threw a whole bunch of errors.

    Have you check the Console?

    #182500
    nixnerd
    Participant

    Have you check the Console?

    this++

    Console is awesome for debugging. Not the only tool you should use… a linter helps too.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.