开发者

Jquery get selector

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 ca开发者_如何转开发n't seem to find a way to do this can some one help please?


If you need to get the id then you can use

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

inside the function.

See attr

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜