How do I use jQuery to set a get url for one element based on its child element?

badwolfff
badwolfff used Ask the Experts™
on
This is my HTML code:
<div class="masonry-hover-wrapper"><div class="hover-desc"><div class="desc-inner"><h3 itemprop="headline" class="entry-title"><a href="http://temp.novelbread.com/informazioni/nutrienti-del-germe/" class="link">Nutrienti del germe</a></h3><div class="desc-wrappper">Welcome to WordPress. This is your first post. Edit or delete it, then start writing! Welcome to WordPress. This is your first post. Edit or delete […]</div></div><div class="links-wrappper clearfix"><a rel="prettyphoto" href="http://temp.novelbread.com/immagini/image-for-vitaminsminerals.jpg" class="zoom"><i class="icon-search"></i></a><a href="http://temp.novelbread.com/informazioni/nutrienti-del-germe/" class="link"><i class="icon-link"></i></a></div></div><div class="image-wrapper scale-with-grid"><a href="http://temp.novelbread.com/informazioni/nutrienti-del-germe/" class="link"><img width="1000" height="577" itemprop="image" alt="image-for-vitaminsminerals" class="scale-with-grid wp-post-image" src="http://temp.novelbread.com/immagini/image-for-vitaminsminerals.jpg"></a></div></div>

Open in new window


I need to be able to click anywhere inside the div (so basically I need to activate a click function on div.masonry-hover-wrapper which should take me to the same url as the link in the child a tag: http://temp.novelbread.com/informazioni/nutrienti-del-germe/

thanks in advance
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015
Commented:
You can add this to a document ready function you already have on the page or create a new one.
<script>
jQuery(document).ready(function(){
	jQuery('div.masonry-hover-wrapper').css('cursor', 'pointer').on('click', function(){
		window.location.href = jQuery(this).find('h3.entry-title a').attr('href');
	});
});
</script>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial