Reputation: 3525
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
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;
}
}
};
This won't change their destination (href
attribute) just cause that clicking them will have no effect whatsoever.
Upvotes: 2