select 框option添加属性 js计算价格 保持两位小数

<select name="" id="">
<volist name="v['childList']" id="n" key="k">
<option value="{pigcms:$n['id']}" price={pigcms:$n['price']} <if condition='$k eq 1'>selected</if>>{pigcms:$n['server']}</option>
</volist>
</select>

 

 

function jisuan(){
var zongjia=0.00;
$('.money option[selected]').each(function(){
zongjia+=parseFloat($(this).attr('price'));
});
$('.dd3 font').text('¥'+zongjia.toFixed(2));
}

posted @ 2015-10-20 16:59  绿尘枫  阅读(376)  评论(0编辑  收藏  举报