Mootools 1.3我如何在“I”中获得if语句;注入;功能?
我需要在采纳代码中使用下面的if语句,但如果它存在,则它是无效的。有没有其他方法可以让我做同样的事情Mootools 1.3我如何在“I”中获得if语句;注入;功能?,mootools,inject,Mootools,Inject,我需要在采纳代码中使用下面的if语句,但如果它存在,则它是无效的。有没有其他方法可以让我做同样的事情 var ele = new Element('li').adopt( new Element('span.title', {text:row.title}), new Element('span.subtitle').adopt( // Need this to work, but its invalid where it is atm if(r
var ele = new Element('li').adopt(
new Element('span.title', {text:row.title}),
new Element('span.subtitle').adopt(
// Need this to work, but its invalid where it is atm
if(row.subtitle = 1)
{
new Element('img', {src:'images/subTitle.png'})
}
),
new Element('span.bold', {text:row.bold}),
);
ele.iject(...
我对MooTools不是很熟悉,但我不明白这为什么不起作用:
var subtitle = new Element('span.subtitle');
if (row.subtitle == 1) subtitle.adopt(new Element('img', {src:'images/subTitle.png'}));
var ele = new Element('li').adopt(
new Element('span.title', {text:row.title}),
subtitle,
new Element('span.bold', {text:row.bold}),
);
如果FTW:
var ele = new Element('li').adopt(
new Element('span.title', {text:row.title}),
new Element('span.subtitle').adopt(
(row.subtitle == 1) ? new Element('img', {src:'images/subTitle.png'}) : null
),
new Element('span.bold', {text:row.bold}),
);
干杯:P应该这样想