开发者

jQuery click on span and travel

<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://开发者_如何学Pythonsite.com
})

Thanks.


You mean this:

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


$(".link").click(function(){
    window.location = "http://example.com";
})

Also it would be a nice touch to add

.link { cursor: pointer; } 


$(".link").click(function(){
    window.location = "http://yoururl.com"
})


$(".link").click(function(){
    $(location).attr('href', $(this).text());
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜