-1

我想使用 jquery mobile 将图像动态添加到网格中。我遵循以下代码jQuery Mobile 网格与图像和标题。但是这里的图像是静态添加的。但是在我的项目中,在运行时我需要将图像添加到网格中,我不知道会有多少,所以我想动态添加它们。所以任何人都可以请建议我如何将图像动态添加到网格中。

我正在使用android中的phonegap插件实现此代码......

提前致谢...

4

1 回答 1

3
you should go through loop and append data to parent div..

Ex:

    <div class ='ui-grid- c' id="parentDiv">

        </div>

    And your code;;
        var Items = [];
            for(var i=0;i< your_data_length:i++){
               //Add your code here
        Items.push("<div class='ui-block-b'><img src="your image source"></div>");  



        }
         $('#perentDiv').append(Items.join(''));
         $('#perentDiv').trigger('create');


    if youcan post your data list , i can post more code ..

/*这将用于 2 列网格。如果需要 maor 列网格,只需在http://jquerymobile.com/test/docs/content/content-grids.html上更改 div 的类。

于 2012-06-10T03:05:53.207 回答