Tuesday, 15 May 2012

Make entire Div clickable using jQuery

$(".myBox").click(function(){
    window.location=$(this).find("a").attr("href");
    return false;
});



Looks for a link inside div with class of "myBox". Redirects to that links value when anywhere in div is clicked.
Reference HTML:


<div class="myBox">
blah blah blah.
<a href="http://google.com">link</a>
</div>