views:

55

answers:

1

I have this jquery script :

$.fn.myFoo = function(){
    alert(this.selector)
    alert($(this).selector);
}

then i call it like so.

$('#myID').myFoo();

I need but it returns empty: i need it to return "myID" i can't seem to find a way to do this can some one help please?

+3  A: 

If you need to get the id then you can use

$(this).attr ( "id" );

inside the function.

See attr

rahul
thank you the $(this).selector works aswell but i had putten it within another function and did not include this. Thank you both
Val