getAttribute不能在IE7中返回类? [英] getAttribute cannot return class in IE7?

查看:71
本文介绍了getAttribute不能在IE7中返回类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据随机属性值找到随机节点。
要做到这一点,我在getElementsByTagName的节点上使用getAtrribute。

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

似乎当我查找类名作为属性时,它不适用于IE(适用于FF)。

It seems like when I look for class name as attribute it does not work on IE (works on FF).

任何人都知道getAtrribute是否仅适用于类或其他属性? (如果只有它我会做一个解决方法。)

Anyone know if getAtrribute doesn't work only on 'class' or other attributes as well? (if its only class I'll do a workaround.)

推荐答案

值得测试你所有的Javascript跨平台,如果你没有使用 jQuery 这样的东西来消除痛苦,但Class可能只是一个特例。

It's worth testing all of your Javascript cross-platform, if you're not using something like jQuery to take the pain away, but Class may just be a special case.

这应该是获得课程的跨平台方式:

This should be a cross-platform way of getting the class:

element.className

这篇关于getAttribute不能在IE7中返回类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆