Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why jQuery show() is not working?

I am using jQuery to hide a div via hide().

Then when a link is clicked it will show the div, but for some reason it will not stay. it will show for a ms then disappear.

HTML

<div id="introContent">
    <h1 id="introText">Welcome</h1>
    <p id="introParagraph">I create <strong>Responsive</strong>, <strong>Interactive</strong>, <strong>Beautiful</strong> Mobile ready Websites.
        Every Website is created from scratch for each client so no Two Projects are alike.
        Please read more about my Company and our work.
        "High Quality Work at Affordable Prices"
    </p>
</div>

jQuery

$(function() {
    $("#introContent").hide();
    $("#intro").click(function () { //$(#intro) is a link in my nav bar 
        $("#introContent").show();
    });
});
like image 869
Mathew Gregory Harrison Avatar asked Jan 15 '15 20:01

Mathew Gregory Harrison


1 Answers

Stop the browser from doing the default action of the element you are clicking. Cancel the click

$(function() {
    $("#introContent").hide();
    $("#intro").click(function (evt) {
        evt.preventDefault();
        $("#introContent").show();
    });
});
like image 60
epascarello Avatar answered Oct 24 '22 16:10

epascarello