答案 0 :(得分:1)
在onchange
货币元素上添加select
侦听器:
<select id="natSelect" onchange="let csymbol = $(this).find(':selected').data('symbol');$('#natCurrency').text(csymbol)">
对每个option
项进行调整:
<option value="<?php echo $black_p['name'];?>" data-symbol="<?php echo $black_p['symbol'] ?>"><?php echo $black_p['name'];?></option>
并将id
添加到span
货币符号元素:
<span class="input-group-addon" id="natCurrency" style="margin-top: 10%;margin-left: -5;margin-right: 15%;">**`symbol_native Here`**</span>
编辑:
要显示默认货币符号,请将此代码插入javascript块:
<script type="text/javascript">
$('#natCurrency').text($('#natSelect').find(':selected').data('symbol'));
</script>