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());
})
精彩评论