简体   繁体   中英

Prevent a button click event to refresh the page

I need to prevent a button to refresh the page it's in. After the first refresh, it just works, but the first time it refreshed the page and it's really annoying.

The button click event sets a display property on "block"

I've already tried every single way suggested here.

<button id="kkBtn_add" style="width:40px;" onclick="addAppointment(); return false;"">+</button>

edit: (removed the double ")

<button id="kkBtn_add" style="width:40px;" onclick="addAppointment(); return false;">+</button>
<script>               
        function addAppointment() {}
</script>

从单击事件中删除返回添加以下代码

<button id="kkBtn_add" style="width:40px;" onclick="addAppointment();">+</button>

下面的代码应该有所帮

<input id="kkBtn_add" style="width:40px;" onclick="addAppointment(); return false;">+</input>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM