I\'d like to build s on the fly in a box based on an AJAX response; i.e. if the responseText is 3, I\'d like to build 3 options:
1<
1条回答 无人及你 (楼主) 2021-01-21 12:27 You can do: var routeSelect = $("#PAG_POSITION").get(0); routeSelect.html(''); //clear-out options if (isNaN(opts) || opts == 0) { //Handles case where your response is invalid or zero routeSelect.append($('').val(0).html(0)); } else { //Add n items to the dropdown for(var i = 0; i < opts; ++i) { routeSelect.append($('').val(i).html(i)); } } Hope this helps. 0 讨论(0) 发布评论: 提交评论 加载中... 自定义标题段落格式字体字号代码语言点击上传x 验证码 看不清? 提交回复
You can do:
var routeSelect = $("#PAG_POSITION").get(0); routeSelect.html(''); //clear-out options if (isNaN(opts) || opts == 0) { //Handles case where your response is invalid or zero routeSelect.append($('').val(0).html(0)); } else { //Add n items to the dropdown for(var i = 0; i < opts; ++i) { routeSelect.append($('').val(i).html(i)); } }
Hope this helps.
热议问题