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

Prototypejs Prototype.js 1.6新元素类和IE>;=9,prototypejs,internet-explorer-9,Prototypejs,Internet Explorer 9,然后我尝试创建一个新元素,例如 new Element('div',{'class':'name'}); 所有浏览器都会创建一个类为“name”的新元素。但在InternetExplorer9和10中,我得到了这个 <div className="name"></div> 正如您所看到的,它创建className属性而不是class。 如何修复此问题?替换 //This generates 'className': var popoutControl = new

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

new Element('div',{'class':'name'});
所有浏览器都会创建一个类为“name”的新元素。但在InternetExplorer9和10中,我得到了这个

<div className="name"></div>

正如您所看到的,它创建className属性而不是class。 如何修复此问题?

替换

//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';
new Element('div',{'class':'name'});

根据元素的建议。类名('name');
已弃用,您应该使用元素。addClassName()。

请在此处查看我的答案:

基本上,Prototype 1.6在IE的这些版本中是有缺陷的。您应该更新Prototype。问题在于元素中包含的翻译列表。\u attributeTranslations.write

这是Prototype 1.7中的列表(我想在上面)

我猜这在旧版本的IE中起作用(在IE9之前可能是最新版本)

var mydiv = new Element('div');
mydiv.addClassName('name');