Posted By

dubogii on 05/17/11


Tagged

div clickable


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jillella
niceslice


Make Entire Div Clickable


 / Published in: jQuery
 

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

  1. $(".myBox").click(function(){
  2. window.location=$(this).find("a").attr("href");
  3. return false;
  4. });
  5.  
  6. Looks for a link inside div with class of "myBox". Redirects to that links value when anywhere in div is clicked.
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. Reference HTML:
  14.  
  15. <div class="myBox">
  16. blah blah blah.
  17. <a href="http://google.com">link</a>
  18. </div>

Report this snippet  

You need to login to post a comment.