如何在HTML中的变量值之前添加$ sign

时间:2012-10-03 09:05:42

标签: javascript html

我有HTML变量存储值835我希望在835之前应该有$这样显示价值$ 835。

same_vaccination_severeei_unvaccinated_val_1.value =  ((parseFloat(mixed_population_ci_unvaccinated_val_1.value) * parseFloat(if_influenza_severe_unvaccinated_val_1.value)/10000)*100).toFixed(2) + $;

2 个答案:

答案 0 :(得分:1)

same_vaccination_severeei_unvaccinated_val_1.value = '$' + ((parseFloat(mixed_population_ci_unvaccinated_val_1.value) * parseFloat(if_influenza_severe_unvaccinated_val_1.value)/10000)*100).toFixed(2);

答案 1 :(得分:0)

试试这个

same_vaccination_severeei_unvaccinated_val_1.value = "$"+((parseFloat(mixed_population_ci_unvaccinated_val_1.value) * parseFloat(if_influenza_severe_unvaccinated_val_1.value)/10000)*100).toFixed(2);