Skip to content

Instantly share code, notes, and snippets.

@maycomayco
Last active July 4, 2018 13:07
Show Gist options
  • Save maycomayco/5b23f5b438b0424d4f2fbdcf27b05ff7 to your computer and use it in GitHub Desktop.
Save maycomayco/5b23f5b438b0424d4f2fbdcf27b05ff7 to your computer and use it in GitHub Desktop.
Helper que permite hacer linkeable un <div> a la URL que tiene seteada el primer elemento <a> dentro de él.
<div class="box">
<h2>Box Title</h2>
<p>The Quick Brown Fox Jumped Over The Lazy Dog</p>
<p><a class="divLink" href="http://www.labnol.org/">Webpage URL</a></p>
</div>
<script>
jQuery(document).ready(function () {
// Or use this to Open link in same window (similar to target=_blank)
jQuery(".box").click(function(){
window.location = jQuery(this).find("a:first").attr("href");
return false;
});
// Show URL on Mouse Hover
jQuery(".box").hover(function () {
window.status = jQuery(this).find("a:first").attr("href");
}, function () {
window.status = "";
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment