Avoid button click effect without affecting other links

3

As I get in jQuery, avoid the click effect of a link that has href="#" without affecting the default behavior of other links.

Example:

I have 3 links

<a href="#">Link 1</a>
<a href="http://www.meusite.com.br/">Link 2</a>
<a href="#">Link 3</a>

What I'm trying to do is that when the user clicks the link with href = #, it does not have that effect going to the top of the page. And at the same time, I want other page links to work normally. I just want to affect the behavior of all <a href="#"></a> .

    
asked by anonymous 09.11.2015 / 14:26

1 answer

1

Instead of # you can put:

<a href="javascript: void(0)"> Link 2 </a>

Or put a class in it:

<a href="#" class="none-link"> Link 2 </a>

CSS

a.none-link{
   pointer-events: none;
}

pointer-events: none - This property with this value discards all events of the element. Click, Hover, Focus, Etc

    
09.11.2015 / 14:29