Posted By

reynish on 09/03/10


Tagged


Versions (?)

Make parent DIV a clickable link using href from a child anchor


 / Published in: jQuery
 

I had a load of divs with 1 link in and I wanted the div to be act as the link.

(add cursor:pointer to the parent Divs css so peeps know they can click it)

  1. $('.parentElement').bind('click', function() {
  2. // Change window.location (Address) to the url from this element inside it
  3. window.location = $(this).find('.linkClass').attr('href');
  4. });

Report this snippet  

You need to login to post a comment.