JavaScript
Article

Make Entire Div Clickable

By Sam Deering

Simple jQuery code snippet to make a div element into a hyperlink so that the user can click anywhere inside and be directed to the link href.

$(".myBox").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});
Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.