a href标签不起作用是为什么

img

img

img

1处的代码阻止链接跳转了,不过可以配置click选项,通过click使用location.href来跳转。有帮助麻烦点个采纳,谢谢,有其他问题可以继续交流~

img

$('#xxxx').SimpleTree({click:function(a){
var href=a.getAttribute('href');
if(href!='#')location.href=href;/////
}})

可以尝试一下楼上第二种 在点击事件中做location.href,你的return false没有实质性意义,不会给你阻止,阻止的前提是你要接收这个false

没问题呢。。点击第一个有链接href的会跳转到csdn问答

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SimpleTree</title>
    <link rel="stylesheet" type="text/css" href="https://www.jq22.com/demo/SimpleTree201703021653/js/tree_themes/SimpleTree.css" />
    <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="https://www.jq22.com/demo/SimpleTree201703021653/js/SimpleTree.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".st_tree").SimpleTree({
                click: function (a) {
                    var href = a.getAttribute('href');
                    if (href != '#') location.href = href;
                }
            });
        });
    </script>
</head>
<body>

    <div class="st_tree">
        <ul>
            <li><a href="https://ask.csdn.net/" ref="hyjm">ASK.CSDN.NET</a></li>
            <li><a href="#" ref="hyjm">欢迎界面</a></li>
            <li><a href="#" ref="xtgl">系统管理</a></li>
            <ul show="true">
                <li><a href="#" ref="yhgl">用户管理</a></li>
                <li><a href="#" ref="rzck">日志查看</a></li>
            </ul>
            <li><a href="#" ref="ckgl">仓库管理</a></li>
            <ul>
                <li><a href="#" ref="kcgl">库存管理</a></li>
                <li><a href="#" ref="shgl">收货管理</a></li>
                <li><a href="#" ref="fhgl">发货管理</a></li>
                <ul>
                    <li><a href="#" ref="yhgl">用户管理</a></li>
                    <li><a href="#" ref="rzck">日志查看</a></li>
                </ul>
            </ul>
        </ul>
    </div>

</body>
</html>