首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Prototype.js 1.6新元素类和IE >= 9

Prototype.js 1.6新元素类和IE >= 9
EN

Stack Overflow用户
提问于 2012-04-08 04:31:58
回答 3查看 745关注 0票数 3

然后,我尝试创建一个新元素,例如

代码语言:javascript
复制
new Element('div',{'class':'name'});

所有的浏览器都会创建一个带有"name“类的新元素。但是在Internet Explorer9和Internet Explorer10中,我得到了这个

代码语言:javascript
复制
<div className="name"></div>

如您所见,它创建className属性而不是类。我该如何解决这个问题呢?

EN

回答 3

Stack Overflow用户

发布于 2012-05-03 03:20:55

代码语言:javascript
复制
//This generates 'className':
var popoutControl = new Element('div', {'class':'mySuperCoolClassName'});

// Break the line up into two lines. 
// The following will generate a 'class' attribute instead:
var popoutControl = new Element('div');
popoutControl.className = 'mySuperCoolClassName';
票数 3
EN

Stack Overflow用户

发布于 2012-05-03 03:32:33

替换

代码语言:javascript
复制
new Element('div',{'class':'name'});

使用

代码语言:javascript
复制
var mydiv = new Element('div');
mydiv.addClassName('name');

根据http://prototypejs.org/api/element/classNames的建议,Element.ClassName('name');已弃用,您应该使用Element.addClassName().

票数 0
EN

Stack Overflow用户

发布于 2013-12-19 05:01:22

请在这里查看我的答案:

https://stackoverflow.com/a/20668126/1274995

基本上,Prototype 1.6在IE的这些版本中是有buggy的。您应该更新Prototype。问题出在Element._attributeTranslations.write中包含的转换列表

这是Prototype 1.7中的列表(以及更高版本,我想)

我猜这在老版本的IE中是有效的(可能是在IE9之前的版本)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10058117

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档