a标签不跳转的几种实现方式

    xiaoxiao2024-03-18  123

    a标签不跳转一共收集了3种方法

    1、onclick事件中返回false

    不能跳转的写法及demo

    <a href="http://www.baidu.com" onclick="return false" >不能跳到百度</a>

    2、 用href=”javascript:void(0)”这种伪协议;(这种伪协议,少写的好)

    <a href="javascript:void(0)" >不能跳转</a>

    3、使用 (#)

    <a href="#" class="demo" onclick="del()" >删除</a>。//总是跳转到当前页面顶部,当页面内容较多时,还是会有跳转的感觉。不推荐使用
    最新回复(0)