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

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

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