Sunday 18 May 2014

Make Entire Div Clickable

$(".myDiv").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="myDiv">
     Some elements or text.
    <a href="your link">link</a>
</div>

No comments:

Post a Comment