我有与酒店房间相关价格的国籍下拉列表。现在我想动态添加显示的价格并输出它。
<div class="Total"></div>
<div class="rum_name">Room name</div>
<div class="nationality">
<select class="sel_nationality" name="nationality">
<option roomprice="30" value="63">SAARC</option>
<option roomprice="50" selected="selected" value="65">American/ European</option>
<option roomprice="45" value="67">Japnese/ Korean</option>
<option roomprice="38" value="69">All Others</option>
</select>
<div class="Price">
Price:
<span class="selectedPrice"></span>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
var total = 0;
$('.sel_nationality').change(function(){
$price = $('option:selected', this).attr('roomprice');
$parent = $(this).parents('.nationality');
$parent.find('span.selectedPrice').text($price);
$tot_price = $(this).val();
$(this).each(function(){
total += parseInt(this.value);
})
$('.Total').text(total);
})
})
</script>
可能有超过 1 个房间和每个房间的上述选项。现在我想根据输出的价格动态更改总数。谢谢