0

私のコード:

document.write('<ul>');
document.write('<li><font color="green">intellectual:</font></li>' + bioEnergy);
document.write('<li><font color="red">emotional:</font></li>' + bioEmot);
document.write('<li><font color="blue">physical: </font></li>' + bioPhy);
document.write('</ul>');

出力:

intellectual:

0.8

emotional:

0.0

physical:

0.0     

私が必要とするのは、次のようにフォーマットすることです:intellectual: 0.8 など。これを機能させるために HTML のスタイルを設定する方法がわかりません。

4

1 に答える 1

2

あなたがすることを意味するのは次のとおりです。

document.write('<li><font color="green">intellectual:</font> ' +  bioEnergy + '</li>');
document.write('<li><font color="red">emotional: </font> ' + bioEmot + '</li>');
document.write('<li><font color="blue">physical: </font> ' + bioPhy + '</li>');

各 document.write 内の要素の順序が変更されていることに注意してください。

出力:

intellectual: 0.8

emotional: 0.0

physical: 0.0  
于 2013-03-23T01:40:34.303 に答える