getAttribute cannot return class in IE7?

后端 未结 5 1698
暖寄归人
暖寄归人 2021-01-04 18:59

I need to find random nodes according to random attribute values. To do that I use getAtrribute on nodes from getElementsByTagName.

It seems like when I look for cl

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 19:28

    IE is broken in this respect. You can access the class in IE via getAttribute("className") but of course this isn't really the attribute so it doesn't work in !IE.

    That leaves you with a choice of branching to get element.className or branching to getAttribute on "className" or "class". Not good.

提交回复
热议问题