How to remove the '#' from a

1

I have a pad on it because I do not want to be redirected anywhere, just look like a link.

But of course, when you click, that pad appears on the route.

How do I remove it?

    
asked by Pelayo 20.02.2018 в 16:02
source

3 answers

5

The href attribute is optional, the only difference is that the cursor will not change when you click on the link, and it will not be underlined (without href it is considered an "anchor" and not a link), but it can be re-added the behavior with CSS, if necessary. But that you can apply to any element.

Also href can be an empty string:

let link=document.getElementById('test');
link.addEventListener('click',()=> alert('Clickado'))
.test {
 cursor: pointer;
 color: blue;
 text-decoration: underline;
 }
<a id="test" class="test"> Esto es un link sin href</a>
<a> Esto es un link si href y sin CSS</a>
<a href=""> Esto es un link a nada</a>

<p class="test"> Esto es un párrafo que simula ser un enlace</p>
    
answered by 20.02.2018 в 16:12
1

You can use javascript: void (0) in the href attribute, this would not go anywhere and you will not add the number sign at the end of the link.

I hope it serves you.

<a href="javascript:void(0)">Link</a>
    
answered by 20.02.2018 в 16:22
0

You can use the void(0) function to avoid using # in your href and thus avoid addressing.

    
answered by 20.02.2018 в 16:05