+1  A: 

You can do it using .prev() and .find() or .children(), like this:

$('.btn').prev('h2').find('a').attr('href');

You can give it a try here. The <a> isn't a sibling so .prev() won't won't work, you have to go back to the <h2> which is a sibling, then go inside it to get the <a> itself.

Nick Craver
Thanks Nick, it worked perfectly!
antoinet
A: 

Close. Really close. You could use the jQuery traversal function .prev() to get the previous element. If you pass a string with the type of element you want it will give you your answer. so something like $('.btn').prev('a') should do the trick. But yeah you had it!

Aaron Hathaway
In this case `<a>` is a nephew, or niece depending on how you think of anchors I guess...but it's not a *sibling* which is all `.prev()` works on :)
Nick Craver
Thanks for your comments, $('.tw_btn').prev('a').attr('href') did not work, but almost ;)
antoinet