我需要一些帮助来计算<p>
段落的数量。我想在代码的span类中显示的数字。我想显示公告的编号。这些项目来自瑞典Trafikverket开放API
我一直在尝试这种方法而没有成功 How can i get the item to count in span?
var htmlResult = '<a href="#popupBasic" id="popupBasicLink" data-close-btn="right" data-position="fixed" data-role="collapsible" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-icon-info ui-btn-icon-left" data-transition="slidedown"><font color="#0040ff">Trafikmeddelanden<span id "test" class="ui-li-count" ></span></font></a>';
htmlResult = htmlResult + '<div data-role="popup" id="popupBasic">';
$(announcement).each(function(iterator, item) {
var startDateTime = new Date(item.StartDateTime);
var hours = startDateTime.getHours();
var minutes = startDateTime.getMinutes();
if (minutes < 10) minutes = "0" + minutes;
var month = startDateTime.getMonth() + 1;
var day = startDateTime.getDate();
var outputDate = startDateTime.getFullYear() + '-' +
(month < 10 ? '0' : '') + month + '-' +
(day < 10 ? '0' : '') + day;
var lastUpdateDateTime = new Date(item.LastUpdateDateTime);
var hours2 = lastUpdateDateTime.getHours();
var minutes2 = lastUpdateDateTime.getMinutes();
if (minutes2 < 10) minutes2 = "0" + minutes2;
var month2 = lastUpdateDateTime.getMonth() + 1;
var day2 = lastUpdateDateTime.getDate();
var outputDate2 = lastUpdateDateTime.getFullYear() + '-' +
(month2 < 10 ? '0' : '') + month2 + '-' +
(day2 < 10 ? '0' : '') + day2;
var externalDescription = item.ExternalDescription;
var reasonCodeText = item.ReasonCodeText;
var countyNo = item.CountyNo;
htmlResult = htmlResult + reasonCodeText.toUpperCase().bold() + '</b><p>Starttid: ' + outputDate + ' ' + hours + ':' + minutes +
' - Uppdaterad: ' + outputDate2 + ' ' + hours2 + ':' + minutes2 +
'<br />' + externalDescription + '</p>';
});
htmlResult = htmlResult + '</div>';
$('#staionInfoMessageDiv').html(htmlResult);
/*
$('#popupBasic').popup();
$('#popupBasic').popup("close");
*/
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="staionInfoMessageDiv"></div>