Nov 19th, 2012
This is useful when you need to make a wrapper clickable when there's a link inside it. Super handy for mobile work. Thanks to Jeremy Tredway for this snippet. Ask him if he has anything better as this code was made in 2012.
// check if empty function notEmpty(val) { return (val != null && val != '' && typeof val != 'undefined') ? true : false; } // init inherited links function initInheritedLinks() { var context = $('body'); context.find('.inherit-permalink').click(function() { var permalink = $(this).find('.permalink:first'); var href = permalink.attr('href'); var target = permalink.attr('target'); if (notEmpty(href)) { if (target == '_blank'){ window.open(href) } else { document.location.href = href; } } }); context.find('.inherit-permalink .permalink').click(function(event) { event.stopPropagation(); }); } /** * initialize functions */ initInheritedLinks();