-2
Is there any way to use links without the tag <a href>
.
For example <a href="exemplo">exemplo</a>
there’s another way to do this?
-2
Is there any way to use links without the tag <a href>
.
For example <a href="exemplo">exemplo</a>
there’s another way to do this?
10
The only alternative is using Javascript, inline in HTML or with event headphone.
You should keep in mind that in terms of SEO and semantics to tag <a>
is the correct one to use. But if you still want to not use an anchor you can use it like this (taking into account the stylization of the mouse pointer, as @Maniero indicated):
HTML
<div id="link" data-link="site.com">exemplo</div>
Javascript
document.getElementById('link').addEventListener('click', function () {
var href = this.dataset.link;
window.location = href;
});
HTML
<div onclick="location.href = 'site.com'">exemplo</div>
Event headphone would be correct Reader ? would not have a more usual word to put or should be this one ?
@Gabrielrodrigues in Portugal is usual, and is an acceptable translation for Liener. In Brazil, we use more when we are at the doctor :) http://michaelis.uol.com.br/moderno/portugues/index.php?lingua=portugues-portugues&palavra=auscultar
5
As a matter of curiosity it might be to do this:
<a id="missionclick" class="moreinfo" style="cursor:pointer;">exemplo</a>
I put in the Github for future reference.
Obviously there is no need to avoid the <a href>
.
1
You can perform the following:
HTML
<a class="meuClick" style="cursor:pointer;">Aqui</a>
In his javascript:
$("a").on('click', '.meuClick', function()
{
//faça algo
}
Using this method, it recognizes even if it is a link from GIFT (or dynamic).
0
Not unlike the answers "inline" already presented but using window.open()
<a onclick="window.open('/','_self', 'noopener')" style="cursor:pointer;">SOpt</a>
The difference is by the second argument: _self
to the same window or _blank
to open in a new tab
Browser other questions tagged javascript html css
You are not signed in. Login or sign up in order to post.
You want this link to be redirected automatically, or the user should click on it?
– Bia
Why not use the href property of the tag ?
– Gabriel Rodrigues