从动态项目中删除 href?
我正在尝试从无序列表项中删除链接 href。
该菜单是由 wordpress 创建的,我试图从第一个项目中删除链接,这样当我用户滚动该项目时,菜单仍然会下拉,但第一个项目(触发下拉的项目)是不可点击。
目前我只有 href="#",但我想完全删除该链接。
我怎样才能去掉 href 元素?
I'm trying to remove the link href from an unordered list item.
The menu has been created by wordpress and I'm trying to remove the link from the first item, so that when I user rolls over the item the menu still drops down but the very first item (the one that triggers the drop down) isn't clickable.
Currently I just have href="#" in place but I'd like to remove the link altogether.
How can I go about stripping out the href element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建菜单项占位符后,从 URL 字段中删除 # 以创建不可点击的下拉占位符。
这可以通过向菜单添加自定义链接并为其分配任何 url(在本例中我刚刚添加 #)然后单击“添加到菜单”来实现。一旦它出现在菜单上,将其打开并删除您分配的网址并保存。如果您最初不输入 URL,WordPress 不会让您将其添加到菜单中。在您的页面上,您将能够将鼠标悬停在其上,并且会出现下拉子子项,但您无法单击父级“占位符”。
注意:此答案来自 WordPress 答案 上的同一问题
After creating the menu item place holder remove the # from the URL field to create the non clickable dropdown place holder.
This is possible by adding a custom link to the menu assigning it any url (for this example I just added #) then click add to menu. Once it's on the menu open it and remove the url you assigned and save. If you don't put the url initially WordPress won't let you add it to the menu. On your pages you will be able to hover over it and the drop down children will appear but you wont be able to click on the parent "place holder".
Note: This answer is from the same question on WordPress Answers
我想你所说的菜单是自动菜单。
我会使用 jQuery 来阻止链接的默认操作。
I am supposing the menu you are talking abou is an automatic one.
I would use jQuery to prevent the default action of the link.