Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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