0

I am trying to create new element and add class for that element.

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

Example Other browsers returns

<div class="name"></div>

IE9 returns

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

How we can fix this issue in prototype.js

4

2 回答 2

0

replace

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

with

var mydiv = new Element('div');
mydiv.addClassName('name');
于 2013-09-27T15:29:54.440 回答
0

The version you are using is buggy in IE9 (Haven't tested other versions of IE, nor other versions of Prototype except the ones below). I advise you to update Prototype. Test this in the console (F12 tools):

Version 1.7:
    (new Element('div', {className: 'buggy'})).outerHTML
        returns "<div class="buggy"></div>"

    (new Element('div', {class: 'buggy'})).outerHTML
        returns "<div class="buggy"></div>"

Version 1.6.0.3:
    (new Element('div', {className: 'buggy'})).outerHTML
        returns "<div className="buggy"></div>"

    (new Element('div', {class: 'buggy'})).outerHTML
        returns "<div className="buggy"></div>"

(Sorry for the late response, I just had to debug this in IE9)

于 2013-12-18T20:50:57.557 回答