Skip to content

Instantly share code, notes, and snippets.

@basvandorst
Created December 19, 2011 17:57
Show Gist options
  • Save basvandorst/1498161 to your computer and use it in GitHub Desktop.
Save basvandorst/1498161 to your computer and use it in GitHub Desktop.
jQuery, make the whole li/div clickable, with target new window. Use the first a-href for the link
$('.clickable')
.has('a')
.css('cursor', 'pointer')
.bind('click',function() {
var href = $('a', this).attr('href')
if($('a', this).is('[rel*=external]')){
window.open(href);
return false;
} else {
window.location = href;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment