The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

javascript help

  • # July 16, 2012 at 8:22 pm

    I am working on a site to get a div to slidetoggle up and down. It seems to be doing it. When I push the link, the div goes down and when I push it again, it goes up. Problem is that when I do push the link which is just an empty link with a class, the page jumps to the top. I need to prevent the default action of the link. I thought I could do it with e.prevendDefault() but that seems to disable the link all together and the div stops working. Do you know how to do this?

    # July 16, 2012 at 8:42 pm

    Should work fine. Here’s a quick demo:

    Just have to make sure to put function(e) before using e.preventDefault().

    Also, not sure if this was the problem, but you misspelled ‘prevent’ in your post.

    # July 16, 2012 at 8:46 pm

    This reply has been reported for inappropriate content.

    thanks Doc, I missed the e in the function(e). That is why it didn’t work. It’s working now.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed