简体   繁体   English

在具有另一个href属性的元素内时,标签无法工作

[英]a tags dont work when inside element with another href attribute

I have come across a problem with nesting two anchor tags in HTML. 我在HTML中嵌套两个锚标记时遇到了一个问题。 Nesting within anchor tags is not allowed, so I tried to workaround it by changing my first a attribute to div . 不允许在锚标记中嵌套,因此我尝试通过将第a属性更改为div来解决此问题。 Funcionality did not change, the link is highlighted and has correct link, however after clicking on the text first href triggers. 功能没有改变,该链接突出显示并具有正确的链接,但是在单击文本后首先触发了href。 Is there any way to workaround this kind of problem? 有什么办法可以解决这种问题?

<div href="#collapse'.$x.'" class="list-group-item list-group-item-info" data-toggle="collapse" data-parent="#affix_sidebar">
    <a href="index.php">'.$cat_name.'</a>
    <span class="glyphicon glyphicon-plus floating_glyphicon"></span>
</div>

What a first href does, is that it triggers a accordion like submenu (shown in image). first href作用是触发类似子菜单的手风琴(如图所示)。 I tried to change the first href attribute not to be in a anchor tag, but I failed. 我试图将第一个href属性更改为不在锚标记中,但失败了。 Second anchor tag (the text) should be link for another page. 第二个锚标记(文本)应该是另一个页面的链接。 Attaching picture for better explanation. 附图片以获得更好的解释。 为了更好的解释

EDIT:// I have though about linking the first href action to the glyphicon only, leaving a attribute only for the text. EDIT://我虽然只想将第一个href动作链接到glyphicon,而只为文本保留一个属性。 My attempts are failing so far, but if anybody would know how to help in this direction I would be thankful. 到目前为止,我的尝试都失败了,但是如果有人知道如何在这个方向上提供帮助,我将非常感激。

在此输入链接的描述如果您要创建下拉菜单,可点击的链接,看的源代码:

[Dropdownmenus][1]

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM