简体   繁体   English

Colspan用于脚本/原型DOM元素

[英]Colspan for Scriptaculous/Prototype DOM elements

I utilized scriptaculose/prototype Builder to create TR and TD. 我利用scriptaculose / prototype Builder来创建TR和TD。 The colspan doesn't work in IE, but it works in FF and Chrome. colspan在IE中不起作用,但在FF和Chrome中起作用。 Do you have any experience on this issue? 您在这个问题上有经验吗?

This doesn't work in IE, but it works in FF and Chrome: 这不适用于IE,但适用于FF和Chrome:

Builder.node('td',{'colspan':'12','class':'bdr-bottom'},(noteText))

This works in IE, FF and Chrome: 这适用于IE,FF和Chrome:

for (var i=1; i<numCols; i++)
{       
    noteRowSpan=Builder.node('td',{'class':'bdr-bottom'},(''));     
    $(noteRow2).insert($(noteRowSpan));  
}       

If you use the new Element() like below you do not need to load the scriptaculous library unless you need the effects - these are built into the code PrototypeJS framework. 如果使用如下所示的new Element() ,则除非需要效果,否则无需加载脚本库-这些效果内置于代码PrototypeJS框架中。

This 这个

Builder.node('td',{'colspan':'12','class':'bdr-bottom'},(noteText))

can be changed to 可以更改为

new Element('td',{'colspan':12,'class':'bdr-bottom'}).update(noteText);

this 这个

for (var i=1; i<numCols; i++)
{       
    noteRowSpan=Builder.node('td',{'class':'bdr-bottom'},(''));     
    $(noteRow2).insert($(noteRowSpan));  
}

can be changed to this 可以更改为此

for(var i=1 ; i<numCols; i++)
{
    noteRowSpan = new Element('td',{'class':'bdr-bottom'});
    $(noteRow2).insert(noteRowSpan);
    //if noteRow2 is created with new Element() you don't need to re-extend it do it like this
    noteRow2.insert(noteRowSpan);
}

EDIT FOR FOLLOWUP 编辑跟进

the parameters of the new Element() method are not the child elements but the attributes of the element you want to create. new Element()方法的参数不是子元素,而是您要创建的元素的属性。

for what you want to do 对于你想做什么

noteRow1= new Element('tr',                           
                   new Element('td',{'class': 'bld rt'},'Date:'),
                   new Element('td').update(noteText)
                   ); 

should be done like this 应该这样

noteRow1= new Element('tr');
noteRow1.insert(new Element('td',{'class': 'bld rt'}.update('Date:'));
noteRow1.insert(new Element('td').update(noteText));

or chained together 或链接在一起

noteRow1= new Element('tr').insert(new Element('td',{'class': 'bld rt'}).update('Date:')).insert(new Element('td').update(noteText));

Also as a note of guidelines - you can click the comment link to ask followup questions 另外,作为准则的注释-您可以单击评论链接以询问后续问题

Thanks. 谢谢。 I am using new Element and it works fine. 我正在使用新的元素,它工作正常。 How to use nested new Elements? 如何使用嵌套的新元素? The code is not working : 该代码不起作用:

noteRow1= new Element('tr',                           
                       new Element('td',{'class': 'bld rt'},'Date:'),
                       new Element('td').update(noteText)
                       );       

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM