Link without using href

-1

Is there any way to use links without the <a href> tag. For example <a href="exemplo">exemplo</a> is there another way to do this?

    
asked by anonymous 04.12.2015 / 10:01

3 answers

7

The only alternative is using JavaScript, inline on HTLM, or with an event handler.

You should note that in terms of SEO and semantics the <a> tag is the correct one to use. But if you still do not want to use an anchor you can use that (given the styling of the mouse pointer, how @bigown pointed out < a>):

event handset

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;
});

inline

HTML

<div onclick="location.href = 'site.com'">exemplo</div>
    
04.12.2015 / 10:39
5

As a matter of curiosity, you can do this:

<a id="missionclick" class="moreinfo" style="cursor:pointer;">exemplo</a>

Obviously there is no need to avoid <a href> .

Font .

    
04.12.2015 / 10:08
1

You can do the following:

HTML

<a class="meuClick" style="cursor:pointer;">Aqui</a>

In your javascript :

$("a").on('click', '.meuClick', function()
{
   //faça algo
}

Using this method, it even recognizes if it is a link coming from DOM (ie dynamic).

    
04.12.2015 / 12:06