jQuery click brings me to top of page. But I want to stay where I am

前端 未结 5 1375
长发绾君心
长发绾君心 2020-12-09 06:14

I have a simple click and show, click and hide button, but when I click it, the page anchors at the top of the page. Is there anyway to prevent this? So that when I click th

5条回答
  •  庸人自扰
    2020-12-09 07:01

    Try returning false in the click function:

    $('#reportThis').hide();
    
    $('#flagThis').click(function () {
            $('#reportThis').show("slow");
            return false;
    });
    $('#submitFlag').click(function () {
            $('#reportThis').hide("slow");
            return false;
    });
    

提交回复
热议问题