Reputation: 13
I want to call a javascript and jump to a specified div
by clicking on Text
.
Here is the javascript I am using:
function hide(parameter) {
document.getElementById(parameter).style.visibility = "hidden"
}
and here the text that should call it:
<a id="text" href="Page.html#foo" href="javascript: hide('text')">Text Text</a>
I just don't know why it doesn't work.
Upvotes: 0
Views: 58
Reputation: 12652
@user3155154's answer is the "best" way to do it, but, if you're interested, this will work too:
<a id="text" href="javascript:hide('text');window.location.href='Page.html#foo';void(0)">Text Text</a>
Upvotes: 0
Reputation: 2614
You cannot add a second href attribute to your a tag. Try onclick instead:
<a id="text" href="Page.html#foo" onclick="hide('text')">Text Text</a>
Upvotes: 4