Site icon Puneet Sharma – Freelance Web Developer

How to make a div act like an anchor tag

Div Anchors
Div Anchors

Using onclick inline javascript to a location can make a div act like an anchor.


<div onclick="location.href='url'">content</div>
jQuery:
$("div").click(function(){
window
.location=$(this).find("a").attr("href"); return false;
});
Exit mobile version