Breezer Breezer -4 years ago 98
jQuery Question

jQuery: select "this" child elements

I'm really going crazy of this particular obstacle, the issue in hand is that I have a very simple table with rows and all. what I'm trying to accomplish is that when you click on a row then this script is suppose to read the link that's stored in the last

td
in the very same row and then direct you there.

What I've come up with so far is this

$('tr td').click(
function (){
alert($(this+':parent td:last-child a:first').attr('href'));
}
);


I've tried 100 of different approaches I either get an error/undefined or I only get the result of the last/first row the rows in-between doesn't work as supposed to.

All help is really appreciated

table looked as following

http://www.jsfiddle.net/xK7Mg/1/

Answer Source

I think you meant to do this:

$('tr td').click(function() {
   window.location.href = $(this).parent().find('td:last-child a:first').attr('href');
});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download