views:

23

answers:

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

How to make this span a link, without adding any inline javascript and extra attributes?

Also without transformation to <a>.

Like this:

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

Thanks.

+3  A: 

You mean this:

$("span.link").click(function(){
   $(this).css('cursor', 'pointer');
   window.location = 'www.example.com';
})
Sarfraz
+1 for `pointer`;
Ben
A: 
$(".link").click(function(){
    $(location).attr('href', $(this).text());
})
Mark Baijens
That would not work, $(this).text() would return move your body, which is not a link.
Mark
+1  A: 
$(".link").click(function(){
    window.location = "http://yoururl.com"
})
Stefanvds
+1  A: 
$(".link").click(function(){
    window.location = "http://example.com";
})

Also it would be a nice touch to add

.link { cursor: pointer; } 
Ben
@Ben: thanks and +1 to you too doing pretty much the similar thing :)
Sarfraz