开发者

Why does the command, alert($(this).attr("id")); return "undefined"?

开发者 https://www.devze.com 2023-01-27 11:08 出处:网络
Why does the command alert($(this).attr(\"开发者_C百科id\")); return \"undefined\"? I\'m using it in ASP NET and Internet Explorer 8.http://api.jquery.com/attr/

Why does the command

alert($(this).attr("开发者_C百科id"));

return "undefined"? I'm using it in ASP NET and Internet Explorer 8.


http://api.jquery.com/attr/

If we try to get the value of an attribute that has not been set, the .attr() method returns undefined.

Maybe some informations are missing? ^^


Either this does not have an ID, or it's not the element you think it is.


I think 'this' is referring to the alert box which I am guessing does not have an attribute called id.

0

精彩评论

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