简体   繁体   English

谁能告诉我为什么我的导航不起作用?

[英]Can anyone please tell me why my navigation doesn´t work?

I can go to the different pages by clicking on MENU, but not back to the first page (index.php).我可以通过单击 MENU 转到不同的页面,但不能返回第一页 (index.php)。

This is the Javascript function, which I put in the head:这是我放在头中的 Javascript 函数:

function toggle_visibility(id) {
            var e = document.getElementById(id);
            e.style.display = (e.style.display === 'block') ? 'none' : 'block';
        }

This is the navigation in the body:这是正文中的导航:

<nav>
            <a href="index.php" onclick="toggle_visibility('menu');
                    return false">
                MENU
            </a>

            <div id="menu" style="display:none;">
                <a href="seite1.php" onclick="toggle_visibility('submenu');
                        return false">
                    POINT1
                </a>
                <div id="submenu" style="display:none;">
                    <a href="seite2.php">
                        POINT 2
                    </a>
                    <a href="seite3.php">
                        POINT 3
                    </a>
                </div>

                <a href="seite4.php">
                    POINT 4
                </a>
                <a href="seite5.php">
                    POINT 5
                </a>
            </div> 

        </nav>

Thank you very much for helping... :)非常感谢您的帮助... :)

the "return false" is preventing the normal action of the <a> link causing the link to not be functional. “return false”阻止了<a>链接的正常操作,导致链接无法正常工作。

you need to remove that in order for it to be a navlink.您需要删除它才能使其成为导航链接。

   <a href="index.php" onclick="toggle_visibility('menu')">
        MENU
    </a>

I am trying to work out why you have the two return falses' in there but I can't see it - you are toggling the visibility of the menu and sub mienu, but I am not sure why the return false is needed.我试图弄清楚为什么你在那里有两个返回假但我看不到它 - 你正在切换菜单和子菜单的可见性,但我不确定为什么需要返回假。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript初学者-谁能告诉我为什么我的按钮不起作用? - Javascript beginner - Can anyone tell me why my button doesn't work? 谁能告诉我为什么我的代码不能正常工作? 游戏石头、纸、剪刀。 Java 脚本 - Can anyone tell me why my code doesn't work properly? Game ROCK, PAPER, SCISSORS. Java Script 有人告诉我为什么这个Jquery在IE中不起作用吗? - Anyone tell me why this Jquery doesn't work in IE? 请告诉我为什么这个表达式不起作用 - Please tell me why this expression doesn't work 谁能告诉我这个 MD Bootstrap Snippet 不起作用? - Can anyone tell me this MD Bootstrap Snippet doesn't work? 我的代码在$(document).ready()函数中不起作用。 谁能帮我理解原因? - My code doesn't work within a $(document).ready() function. Can anyone help me understand why? 有人可以告诉我为什么这个js函数无法在加载时运行吗? - Can someone please tell me why this js function doesn't run on load? 谁能告诉我为什么我的警报没有触发? 娜达(Zada) - Can anyone tell me why my alert(id) isn't firing off? Nada, zilch, zippo 谁能告诉我为什么我的投影透视矩阵不起作用? - Can anyone tell me why my projection perspective matrix isn't working? 任何人都可以告诉我为什么我的脚本禁用了s键吗? - Can Anyone tell me why my script is disabling the s key?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM