开发者

the div that show() called disappeared in the next second

开发者 https://www.devze.com 2023-04-10 23:24 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号