HTML tag redirect blocking

I use the following code for just a dialog box, its work is fine. But how can I stop redirecting the same page when clicked?

<a href="" title = "this is some text">[?]</a> 

Thanks in advance...

+5
source share
3 answers

If you do not want to contact anywhere: do not use the link in the first place.

 <span title = "this is some text">[?]</span> 

(If you are creating something to click on (which launches JS), use <button> ).

+1
source

add # like this:

 <a href="#" title = "this is some text">[?]</a> 

or remove href links and set the url in some kind of custom attribute

onclick link event, reading url from user attribute

 <a href="#" onclick="JSFunction()" id="someid" data-url="some url">text</a> 
+2
source

You can try the following:

 $(document).on('click', '.click', function(e){ e.preventDefault(); e.stopImmediatePropagation(); return false; }); 

JSFIDDLE

+2
source

Source: https://habr.com/ru/post/1215405/


All Articles