【发布时间】:2021-02-10 20:01:51
【问题描述】:
我有一个带有标签的列表,项目值是通过在线电子表格获得的。选择选项时,该值不会实时显示在 html 中。有谁能够帮助我?我正在尝试解决它,但我找不到错误。
$(document).ready(function() {
var sheetURL =
"https://spreadsheets.google.com/feeds/list/1J0qyxUCCkvcFGZ6EIy9nDOgEuTlpI5ICVG3ZsBd_H-I/1/public/values?alt=json";
$.getJSON(sheetURL, function(data) {
var entryData = data.feed.entry;
console.log(data);
jQuery.each(entryData, function() {
$("#divTax").append(
'<option hidden="hidden" selected="selected" value="0">CHOISE</option><option value="' + this.gsx$values.$t + '">' + this.gsx$names.$t + ' $' + this.gsx$values.$t + '</option>'
);
});
});
});
var totalWithTax = $('#divTax :selected').val();
$('.total').html(totalWithTax);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<select style="width: 80%;" id="divTax"></select>
<br>
Total:<div class="total"></div>
【问题讨论】:
-
您似乎缺少像 $('select').on('change', function () 或 $('#divTax').on('change',函数()
标签: javascript html jquery google-sheets