3

I want to create a link that does NOTHING, it means that its a fake link

Im trying with onclick="mijava();return false;" but it scrolls up in the website

How can I do it?

shurperro
  • 47
  • 2
  • 5
  • 1
    Why do you want to create a link that does nothing? This sounds like an XY problem: you have one problem, and you think that creating an `a` element that does nothing will solve it. So... what is the issue you're trying to solve? – Mr Lister Oct 22 '15 at 16:41

5 Answers5

3

javascript:

document.getElementById("nothing").addEventListener("click", function(event){
event.preventDefault()
});

html:

<a id="nothing" href="#">Link</a>

JSFiddle

Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47
3

"javascript:void(0)" to href attribute, the <a> tag will do nothing.

sticky bit
  • 36,626
  • 12
  • 31
  • 42
wilfredinni
  • 43
  • 1
  • 7
2

This won't do anything.

<a href="">Link</a>
0

You can use CSS to style it like a link and you probably don't want to use an anchor tag if it's not going to act like one.

See this answer: How to make an anchor tag refer to nothing?

Community
  • 1
  • 1
Elliott
  • 2,035
  • 20
  • 23
0

Do you test it that?

<a href="#">link</a>
C.B.
  • 194
  • 4
  • 15