the div that show() called disappeared in the next second
When I click the div that suppose to show, it just showed in a second and then disappeared. How do I make it stay display on the page?
Here is the开发者_如何学Python code
<div class="circle0">
<h4><a href="" id="show_1">sketch & drawing</a></h4>
</div>
<div class="sec_down" style="display: none;">
<h1>{Mask}</h1>
</div>
<script>
$("#show_1").click(function () {
$(".sec_down").show();
});
</script>
You need to prevent the default click handling in the link so it won't process the href in the link and reload the page. in jQuery, you can do that by adding return(false)
to the click handler:
<div class="circle0">
<h4><a href="" id="show_1">sketch & drawing</a></h4>
</div>
<div class="sec_down" style="display: none;">
<h1>{Mask}</h1>
</div>
<script>
$("#show_1").click(function () {
$(".sec_down").show();
return(false); // prevent default handling of the click
});
</script>
Change href=""
to href="#"
or break the default action of the link by using return false
.
精彩评论