views:

41

answers:

2

Hi, I'm just getting started with jQuery and I want to get the url of a selected element so I can do something with it.

To start with I'm just trying to get the url of a hovered link to show up in an alert. Can anyone tell me where I'm going wrong?

$(function() {

   $("table#content > tbody > tr > td > a[href*=delete]").hover(function(event){

   alert(this.value);

   });

});

Any help would be appreciated.

Thanks.

+3  A: 

try:

alert(this.href);

In your hover callback this represents the element which according to your selector I assume is an anchor tag. To get the URL this anchor points to you use the href attribute.

Darin Dimitrov
Thanks! That's great.
Dan
A: 

I'm not much of a JS person myself, but I came up with this solution to a similar problem; only not involving tables.

Hope it helps.

konzepz