• flickr
  • linkedin
  • twitter
  • rss
Make a whole DIV a link the easy way with Jquery

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:

Larry's a 30-something chap interested in travel, being a dork and changing the world via less boring training.

Leave a reply