Make a whole DIV a link the easy way with Jquery

<script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script>

<script type="text/javascript">

function init() {

$(".simBox").click(function(){
     window.location=$(this).find("a").attr("href");
window.open($(this).find("a").attr("href"));
     return false;
});

$(".simBox").mouseover(function(){
$(this).addClass("simBoxOver");
});
$(".simBox").mouseout(function() {
$(this).removeClass().addClass("simBox");
});


}


$(document).ready(function() {
   init();
});


</script>

</head>

<body>
How do I...<br><br>
<div class="simBox"><a href="about:blank">Enrol in elearning?</a></div>

Src: http://css-tricks.com/snippets/jquery/make-entire-div-clickable/

Tech Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑