jQuery Clickable Div Based on Internal Link

Glenn Uncategorized 0 Comments

If you want a div to be clickable based on a standard HTML internal link, within that div, then use this jQuery snippet (requires jQuery Library):-


jQuery(document).ready(function($) {
$(".parent-div").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
});

The code will rattle through the parent div looking for links and will then add the link it to that div. Useful for components that require clickable divs with custom defined structured content (portfolio grids etc).

About the Author
jQuery Clickable Div Based on Internal Link 0da77002febbfe28d15144a57bbcc2c9 s 180 d mm r g

Glenn

A highly experienced WordPress Web Developer, Front-end and Back-end Developer & New Media Specialist with extensive knowledge of a wide spectrum of technologies in the Development and Creative Industries built up over a number of years.

Leave a Reply

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