How do you make a div tag into a link
How do you make a div tag into a link. I would like my entire div to be clickable.
JS:
<div onclick="location.href='url'">content</div>
jQuery:
$("div").click(function(){
window.location=$(this).find("a").attr("href"); return false;
});
Make sure to use cursor:pointer
for these DIVs
If you're using HTML5, as pointed in this other question, you can put your div
inside a
:
<a href="http://www.google.com"><div>Some content here</div></a>
Preffer this method as it makes clear in your structure that all the content is clickable, and where it's pointing.