然后,我尝试创建一个新元素,例如
new Element('div',{'class':'name'});所有的浏览器都会创建一个带有"name“类的新元素。但是在Internet Explorer9和Internet Explorer10中,我得到了这个
<div className="name"></div>如您所见,它创建className属性而不是类。我该如何解决这个问题呢?
发布于 2012-05-03 03:20:55
//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';发布于 2012-05-03 03:32:33
替换
new Element('div',{'class':'name'});使用
var mydiv = new Element('div');
mydiv.addClassName('name');根据http://prototypejs.org/api/element/classNames的建议,Element.ClassName('name');已弃用,您应该使用Element.addClassName().
发布于 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之前的版本)。
https://stackoverflow.com/questions/10058117
复制相似问题