Skip to content

Instantly share code, notes, and snippets.

@karloscarweber
Created March 14, 2012 16:53
Show Gist options
  • Save karloscarweber/2037835 to your computer and use it in GitHub Desktop.
Save karloscarweber/2037835 to your computer and use it in GitHub Desktop.
This Snippet basicly finds an 'a' element inside another element, then redirects to it's HREF
// This Snippet basicly finds an 'a' element inside another element, then redirects to it's HREF
// useful for faking link behaviour on block level elements, without having to make them a tags.
// be careful to have a fallback for when javascript is disabled.
$(document).ready(function(){
// onclick obviously
$('element').click(function(){
// $(this) refers to jquery object passed inot he method. it would be of 'element' in this case.
var href = $(this).find('a').attr("href");
// for debugging purposes.
/*console.log(href);*/
// now lets send us to the href.
window.location = href;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment