Make an Entire Div Clickable

Supplemental 175 views
-1
0 Flares 0 Flares ×

Here’s an easy way to make the parent div of a link clickable.

HTML

<div class="myBox">
     blah blah blah.
    <a href="http://google.com">link</a>
</div>

jQuery

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

For Reference:

Make Entire Div Clickable

Provided by: Cats who Code
Posted in jQuery

Discuss:

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

No Trackbacks.

Login

Register | Lost your password?
0 Flares Twitter 0 Facebook 0 Google+ 0 0 Flares ×