社区
JavaScript
帖子详情
js className的兼容性问题
小伙真帅
2010-01-02 05:25:36
如果我要通过JS进行元素的class赋值。要怎么样才能做到兼容性最好?
我用ele.className="style"在FF下无效
...全文
492
12
打赏
收藏
js className的兼容性问题
如果我要通过JS进行元素的class赋值。要怎么样才能做到兼容性最好? 我用ele.className="style"在FF下无效
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
12 条
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
打赏红包
jian_deyang
2011-03-31
打赏
举报
回复
className直接赋值是没有问题的,但是getAttribute和setAttribute,FF只能用class,IE只能用className
浴火_凤凰
2010-01-04
打赏
举报
回复
className是通用的
楼主看看其他地方也没有问题吧
xmliy
2010-01-03
打赏
举报
回复
你的css有一个地方写错了!
.hidden{filter:alpha(opacity=50);
opacity=0.50
;width:138px; height:120px; border:none;}
应改为:
.hidden{filter:alpha(opacity=50);
opacity:0.50
;width:138px; height:120px; border:none;}
小伙真帅
2010-01-03
打赏
举报
回复
但是在IE下是支持的啊。
大家可以看一下这里的效果:
http://www.net1573.com/demo/liu
licip
2010-01-02
打赏
举报
回复
是的。className是通用的呀。看看是不是其它方面的问题。
antony1029
2010-01-02
打赏
举报
回复
[Quote=引用 4 楼 hookee 的回复:]
className ff也支持的,可能问题不是出在这里.
[/Quote]
是这样的
hookee
2010-01-02
打赏
举报
回复
className ff也支持的,可能问题不是出在这里.
skyboxgogo
2010-01-02
打赏
举报
回复
[Quote=引用楼主 ccppvv 的回复:]
如果我要通过JS进行元素的class赋值。要怎么样才能做到兼容性最好?
我用ele.className="style"在FF下无效
[/Quote]
ele.style.className="style"就行了 。
东大坡居士
2010-01-02
打赏
举报
回复
么有问题~
孟子E章
2010-01-02
打赏
举报
回复
没有问题a
<style>
.a{color:#000}
.b{color:#f00}
</style>
<input onclick="this.className='b'" class="a" value="xxx"/>
hehuan1213
2010-01-02
打赏
举报
回复
className ff也支持的
xmliy
2010-01-02
打赏
举报
回复
较早版本的FF并不支持className,试试
ele.setAttribute(document.all ? 'className' : 'class', 'style');
相关推荐
js
jquery 判断元素是否有指定
Class
js
方法: //第一种方法,用
class
List这个H5 API,有
兼容性问题
if(p[i].
class
List.contains(‘test’)==true){ } //第二种方法,用
class
Name这个属性 if(p[i].
class
Name==‘test’){ } //第三种方法,用getAttribute()这个方法 if(p[i].getAttribute(“
class
”)==‘test’){ } 以上三种可以任选,条件是不考虑兼容性和多个
class
名的情况 jquery方法: if(p[i]
JS
中setAttribute的
兼容性问题
(摘自leejersey)
class
和
class
Name兼容方法: object.setAttribute("
class
","content") 在IE8、Chrome、火狐、Opera10中都能设置成功;但是在IE7下无法设置。 object.setAttribute("
class
Name","content") 只有IE7能设置成功,但是其他浏览器均无法设置。 兼容方法: 使用object....
js
一些方法的
兼容性问题
原博文地址http://www.cnblogs.com/leejersey/archive/2013/02/20/2919052.html
js
中setAttribute 的兼容性
class
和
class
Name兼容方法: object.setAttribute("
class
","content") 在IE8、Chrome、火狐、Opera10中都能设置成功;但是在IE
android dlna uri,DLNA开发中
兼容性问题
//getElementsBy
Class
Name兼容functiongetElementsBy
Class
Name(node,
class
name){if(node.getElementsBy
Class
Name//getElementsBy
Class
Name兼容functiongetElementsBy
Class
Name(node,
class
name){if(node.getElementsByC...
getElementsBy
Class
Name
兼容性问题
//getElementsBy
Class
Name兼容 functiongetElementsBy
Class
Name(node,
class
name){ if(node.getElementsBy
Class
Name){ //判断有这个方法,则使用原来的方法; returnnode.getElementsBy
Class
Name("
class
name"); }els...
发帖
JavaScript
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
8.7w+
社区成员
22.4w+
社区内容
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
帖子事件
创建了帖子
2010-01-02 05:25
社区公告
暂无公告