.attr("id") in jQuery 1.6.1
I am using
jQuery(somethin开发者_开发知识库g).attr("id")
in jQuery 1.6.1 and seem to be getting issues with this - basically, it's returning blank ?
I thought all the issues with 1.6.1 resolved backwards compatibility etc for the .attr
or ?
Use something.id
(if its a HTMLElement
)
or $(something)[0].id
(if it's a selector string)
Maybe the selector you are using is returning an array of objects. In which case you need to do:
jQuery(something).each(function(){
var id = $(this).attr("id");
//Do what ever you need to with each id
});
Or just select the first element.
精彩评论