3

次に、たとえば、新しい要素を作成しようとしています

new Element('div',{'class':'name'});

すべてのブラウザーは、クラス "name" を持つ新しい要素を作成します。しかし、Internet Explorer 9 および 10 では、これを取得しました。

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

ご覧のとおり、クラスの代わりに className 属性を作成します。どうすればこれを修正できますか?

4

3 に答える 3

3
//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-02T19:20:54.633 に答える
0

ここで私の答えを見てください:

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

基本的に、これらのバージョンの IE では Prototype 1.6 にバグがあります。プロトタイプを更新する必要があります。問題は、Element._attributeTranslations.write に含まれる翻訳リストです。

プロトタイプ 1.6.0.3 の Object Element._attributeTranslations.write

これはPrototype 1.7のリストです(そしてそれ以上だと思います)

プロトタイプ 1.7 以降の Element._attributeTranslations.write

古いバージョンの IE で動作したと思います (おそらく IE9 より前のバージョンでした)。

于 2013-12-18T21:01:22.110 に答える
0

交換

new Element('div',{'class':'name'});

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

http://prototypejs.org/api/element/classNames Elementから提案されているとおり。ClassName ('名前'); Element を使用する必要があります。addClassName ()。

于 2012-05-02T19:32:33.293 に答える