将JavaScript数组值附加到Dojo Div
-
12-11-2019 - |
题
我有一系列值,如上所示。
myarray2.push("10-FEB-11");
myarray2.push("11-FEB-11");
myarray2.push("12-FEB-11");
myarray2.push("13-FEB-11");
myarray2.push("14-FEB-11");
.
我希望在div hrxaxisslider内有这些值,如图所示(目前它的硬编码,但可能)
<div id="hrXAxisSlider"
dojoType="dojox.form.HorizontalRangeSlider">
<ol dojoType="dijit.form.HorizontalRuleLabels" >
<li>10-FEB-11</li><li>11-FEB-11</li><li>12-FEB-11</li><li>13-FEB-11</li><li>14-FEB-11</li>
</ol>
</div>
. 解决方案
您可以通过简单的JavaScript来完成此操作:
var ol = document.getElementById('hrXAxisSlider')
.getElementsByTagName('ol')[0],
ma2l = myarray2.length,
i,
htmlFrag = '';
for (i = 0; i < ma2l; i++) {
htmlFrag += '<li>' + myarray2[i] + '</li>';
}
ol.innerHTML = htmlFrag;
.
不隶属于 StackOverflow