Waymond
Waymond

Reputation: 257

content not showing when clicking nav

I'm trying to figure out why my jquery isn't working correctly. I click on my navbar link and the content space shows for .0923202 of a second and goes back to be hidden. Thank you.

$(document).ready(function() {

    $(".content").hide();

    $("a").click(function() {
        $(".content").show();

    });
});

http://jsfiddle.net/NHgpg/

Upvotes: 1

Views: 55

Answers (1)

Robbert
Robbert

Reputation: 6582

While anchor tags are meant to send users to another page, you're using it to show new content on the page. You will want to return false to override the default behavior of the anchor tag

$(document).ready(function() {
    $(".content").hide();

    $("a").click(function() {
        $(".content").show();
        return false;
    });
});

Upvotes: 2

Related Questions