开发者

.attr("id") in jQuery 1.6.1

开发者 https://www.devze.com 2023-03-13 06:31 出处:网络
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 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.

0

精彩评论

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