动态画廊

How would you write the below code in jQuery?

I have the code working in php, it is to create a way of added a list item with light box and an image. Without having the write each img src and lightbox link out.

<?php

                        $images = range(1, 3);

                        $rowCount = 0;

                        foreach ($images as $image) {
                        // stripping stuff:
                        echo '<li class="search-dogs"';


                          echo '><a href="images/gallery/search-dogs/'.$image.'.jpg" rel="lightbox[gallery]">
                              <img src="images/gallery/search-dogs/'.$image.'.jpg">
                            </a></li>';
                        }

       ?>
douhan4243
douhan4243 完整的答案不是必需的只是一些指针或有用的信息是可以的。呼吸
4 年多之前 回复
dqg17080
dqg17080 StackOverflow不是代码转换服务。
4 年多之前 回复

1个回答

 var images = [1,2,3];
 var rowCount = 0;
 var TargetElement = 'body'; //html tag, .classTag, #htmlElementId
 for(var image in images) {
     // stripping stuff:
      $(TargetElement).append('<li class="search-dogs"><a href="images/gallery/search-dogs/'+image+'.jpg" rel="lightbox[gallery]"><img src="images/gallery/search-dogs/'+image+'.jpg"></a></li>');
 }
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐