Skip to content

Instantly share code, notes, and snippets.

@maoyama
Created December 7, 2012 08:50
Show Gist options
  • Save maoyama/4231890 to your computer and use it in GitHub Desktop.
Save maoyama/4231890 to your computer and use it in GitHub Desktop.
blocklink.js
//指定した要素内のリンクを取得して、要素全体をクリック可能にする。
$(function(){
$('.blocklink a').each(function(){
var href = $(this).attr('href');
var target = $(this).attr('target');
$(this).parent().click(function() {
if(target){
window.open(href,'_blank');
}else{
document.location = href;
}
return false;
});
$(this).parent().hover(function(){
$(this).css({cursor:'pointer'});
$(this).children('a').css({textDecoration:'underline'});
},function(){
$(this).children('a').css({textDecoration:'none'});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment