Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Scroll to specific object on click

Scroll to specific object on click

Scheduled Pinned Locked Moved General Discussion
6 Posts 3 Posters 2.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    T
    ThibaultDuchesne
    wrote on last edited by
    #1

    Hi !
    I've been using Lay Theme since a bit, and I'm currently trying to push a little further my website.
    I basically try to create a scroll to specific object on lick function (combining with the click events, to have scroll on click with all objects with a specific class)
    I've been looking at the guidelines in the "custom script" documentation section, especially the "Binding Click Events", but I tried and seems that it's not working (nothing in the log when clicking...)
    How could we apply that short simple code ? (combining the click events with a scroll to function)

    <script>
    $("button").click(function() {
    $('html,body').animate({
    scrollTop: $(".second").offset().top},
    'slow');
    });
    </script>

    Thank you very much!

    Thibault

    1 Reply Last reply
    0
    • arminunruhA
      arminunruhA
      arminunruh
      Global Moderator
      wrote on last edited by arminunruh
      #2

      Hey thibault, you are binding your click event directly to an element. But you need to bind it in a delegated way like i explain in the documentation:

      <script>
      jQuery("body").on("click", "button", function(event) {
      console.log("yay!");
      });
      </script>

      This code will console log yay everytime you click a dom element "button". If u want to bind the click to an element that has the class button you should use ".button" instead of "button"

      1 Reply Last reply
      0
      • T
        T
        ThibaultDuchesne
        wrote on last edited by
        #3

        Hey! I tried exactly with the code you suggested in the documentation

        <script>
        jQuery("body").on("click", ".clickme", function(event) {
        console.log("yay!");
        });
        </script>

        and gave a class clickme to an image (with the little class button)
        But nothing appears in the log when I click on it... it's in a project page, I'm using arrows (previous/next) on that page also. The mouse pointer doesn't change, and nothing appears in the logs... I tried on a clickable object (a button) still nothing.

        What do you think that could be ? I tried the other script you suggested in the doc Newpage Events, and some stuffs appear in the log that time.

        Thnks !

        1 Reply Last reply
        0
        • arminunruhA
          arminunruhA
          arminunruh
          Global Moderator
          wrote on last edited by
          #4

          Hey can u send me your laytheme website address and wordpress login please? You can send that via chat or email to: armin.unruh@gmail.com
          Please also provide a link to this forum thread so that I remember what the problem is.

          1 Reply Last reply
          0
          • T
            T
            ThibaultDuchesne
            wrote on last edited by ThibaultDuchesne
            #5

            I actually just solved it ! I entered the scripts in the Top and not in the Head now it's working fine ! Thanks

            Hayo GebauerH 1 Reply Last reply
            0
            • T ThibaultDuchesne

              I actually just solved it ! I entered the scripts in the Top and not in the Head now it's working fine ! Thanks

              Hayo GebauerH
              Hayo GebauerH
              Hayo Gebauer
              wrote on last edited by
              #6

              @ThibaultDuchesne
              Hey Thibault:
              could you explain how you made it happen?

              1 Reply Last reply
              0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              Online Users
              A
              Anna_S
              Z
              zachludlow
              Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
              laytheme.com
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Recent
              • Tags
              • Popular
              • Users
              • Search