将Javascript数组值附加到DOJO div [英] Appending Javascript Array Values to the DOJO div

查看:86
本文介绍了将Javascript数组值附加到DOJO div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如上所示的数组值。

I have a Array of Values as shown above .

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中显示这些值,如图所示(目前其硬编码,但可能)

I want to have these Values inside the div hrXAxisSlider as shown (Currently its hardcoded , but is that possible )

  <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 for循环完成此操作:

You can accomplish this with a simple javascript for loop:

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;

参见示例&#x2192;

这篇关于将Javascript数组值附加到DOJO div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆