move your body How to make this range a link without adding inline javascript...">

JQuery click on spacebar and drive

<span class="link">move your body</span>

How to make this range a link without adding inline javascript and additional attributes?

Also without conversion to <a>.

Like this:

$(".link").click(function(){
    // go to the http://site.com
})

Thank.

+3
source share
4 answers

You mean this:

$("span.link").click(function(){
   $(this).css('cursor', 'pointer');
   window.location = 'www.example.com';
})
+9
source
$(".link").click(function(){
    window.location = "http://example.com";
})

It would also be nice to add

.link { cursor: pointer; } 
+3
source
$(".link").click(function(){
    window.location = "http://yoururl.com"
})
+1
source
$(".link").click(function(){
    $(location).attr('href', $(this).text());
})
0
source

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


All Articles