繁体   English   中英

如何在phoneGap中创建动态ListView

[英]How to create a dynamic ListView in phoneGap

我一直在努力在HTML中创建动态的带下划线的列表。 我正在创建一个Phone Gap应用程序,在其中我向服务器请求并获取一些数据。 根据此数据,我必须在列表中显示此数据,并且数据是动态的,因此我必须创建一个动态列表。 请事先帮助我

在html中创建动态列表并不是什么大不了的。我只是为您提供代码。

function addOptioncity() { 

    var strs = cityarray;  //this is a array
    var list = document.getElementById('cityidm');

               for (var i in strs) {

                var anchor = anchor+i;
                    anchor = document.createElement("a");
                    anchor.href = "#";
                    anchor.innerText = "neeraj";
                    anchor.value = "10";
                $(anchor).on("click",function(){
                   //currentcityval=this.value;
                   //currentcityname=this.innerText;
                   //refresh();

                });
                if(i==0)
                 { 
                   currentcityval=anchor.value;
                   currentcityname=anchor.innerText;
                 }


                var elem = document.createElement("li");
                           elem.appendChild(anchor);
                           list.appendChild(elem);

                }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM