阻止下拉扩展页面加载

时间:2018-03-23 17:08:11

标签: javascript html css

<li>
    <a href="#">
        <span class="icon"><i class="icon20 i-stack-list"></i></span>
        <span class="txt">Smartr Sites</span>
    </a>
    <ul class="sub">
        <li>
            <a href="tables.html">
                <span class="icon"><i class="icon20 i-stack-list"></i></span>
                <span class="txt">Chicken Notes</span>
            </a>
        </li>
        <li>
            <a href="data-tables.html">
                <span class="icon"><i class="icon20 i-stack-list"></i></span>
                <span class="txt">Purely Commerce</span>
            </a>
        </li>
    </ul>
</li>

我的仪表板子菜单会自动展开而不会点击页面加载。我点击它时只想展开或关闭。 也许可以通过JS调整来完成。

enter image description here

1 个答案:

答案 0 :(得分:0)

好的,谢谢你的帮助,但我找到了一种方法来实现这一目标。我只是将id放在下拉菜单中并应用了与该id相关的JS函数。这是:

<li>
    <a href="#"id="posuvnik">
        <span class="icon"><i class="icon20 i-stack-list"> 
     </i></span>
        <span class="txt">Smartr Sites</span>
    </a>
    <ul class="sub">
        <li>
            <a href="tables.html">
                <span class="icon"><i class="icon20 i-stack-list"></i></span>
                <span class="txt">Chicken Notes</span>
            </a>
        </li>
        <li>
            <a href="data-tables.html">
                <span class="icon"><i class="icon20 i-stack-list"></i></span>
                <span class="txt">Purely Commerce</span>
            </a>
        </li>
    </ul>
</li>

</script>
  $(document).ready(function () {
    $("#posuvnik").click();
  });
</script>