Chobeat
Chobeat

Reputation: 3525

Hide link in html

I need to hide a link to the user so that he can't click it to get to another page but I have several JS scripts and CSS that would take too much work to change so I need the document structure to stay the Same.

How can I achieve that?

This is an example

<span>
<a href="xxx">text</a>
</span>

I obviously tried to generate this instead

<span>text</span>

but selectors can't find the text because there's no "a" tag.

How can I achieve that?

Upvotes: 2

Views: 4902

Answers (2)

Shadow Wizzard
Shadow Wizzard

Reputation: 66388

To disable all the links, have such code:

window.onload = function() {
    for(var i = 0; i < document.links.length; i++) {
        document.links[i].onclick = function() {
            return false;
        }
    }
};​

Live test case.

This won't change their destination (href attribute) just cause that clicking them will have no effect whatsoever.

Upvotes: 2

Sjoerd
Sjoerd

Reputation: 75659

Set style="display: none" to not display it at all.

Upvotes: 0

Related Questions