Created
March 14, 2012 16:53
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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