我在codeigniter中有以下内容:
foreach($created_rates as $rate)
{
echo
'<div class="radio">
<label>
<input type="radio" value="'.$rate->id.'" data-rate="'.$rate->rate.'" name="shipmentRate" id="shipmentRate"/>'.str_replace('_', ' ', $rate->service).' $'.$rate->rate.'
</label>
</div>';
}
我试图通过java脚本获取数据速率,我在java脚本中有以下内容:
<script>
$("#shipmentRate").on('change', function(){
var shipmentRate = $(this).data('rate');
alert(shipmentRate);
})
</script>
这不是警告任何内容或在谷歌Chrome控制台中给出任何错误