Search code examples
htmlhrefhidden

Link (Href) to a hidden (display:none) html element


I've a problem with anchor tags :/

I've got the following code:

<div name="divA">
<a name="A"> A</a>
</div>

<div name="divB" style="display: none;">
<a name="B"> B</a>
</div>

<div name="divHrefB">
<a href="#B">B</a>
</div>

My goal is that when i click on B (divHrefB) the application go to "divB" but since this element hidden it doesn't work.

Please note, that i don't want to show divB (i want a link to the place where div are... is that possible?

At this point, i'm thinking on generate dynamically the href value (in this case, i would generate the following div)

<div name="divHrefB">
<a href="#A">B</a>
</div>

Thanks a lot.


Solution

  • just don't apply display: none, just add this css for the hidden div.

    <div name="divHrefB" style="height: 0px;width: 0px;overflow:hidden;">
    <a href="#A">B</a>
    </div>