Clickable Div Using Jquery

September 4th, 2009 @

An update to an old post. I found a much cleaner solution using jquery.

The setup:

<div id="clickable">
  <h2><a href="#">Clickable Text</a></h2>
</div>

Now the jquery:

$(document).ready(function(){

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

});

A nice clean solution that plucks the link from the div and makes the entire thing clickable.

Leave a Reply