title: How to append 12 images in a row continuosly using javascript
body: <pre><code>function stripTags(s, n) {
      return s.replace(/&lt;\/?(?!br\s*\/?)[a-z][a-z0-9]*[^&lt;&gt;]*&gt;/ig, "").split(/\s+/).slice(0, n - 1).join(' ');
  }
  
  function rm(a, b, c) {
      var p = document.getElementById(a);
      var summ = summary;
      var summ = summary;
      imgtag = "";
      var i = 0;
      img = p.getElementsByTagName("img");
      imgsrc = img[i].src;
      var q = document.getElementById(b);
      var r = document.getElementById(c);
  
      for (var i = 0; i &lt; img.length; i++) {
          if (img.length &gt;=12) imgtag = '&lt;a class="featured_gallery" href="' + imgsrc + '"&gt;&lt;img src="' + imgsrc + '" /&gt;&lt;/a&gt;';
          else if (img.length &gt;=8) imgtag = '&lt;a class="featured_gallery" href="' + img[0].src + '"&gt;&lt;img src="' + img[0].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[1].src + '"&gt;&lt;img src="' + img[1].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[2].src + '"&gt;&lt;img src="' + img[2].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[3].src + '"&gt;&lt;img src="' + img[3].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[4].src + '"&gt;&lt;img src="' + img[4].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[5].src + '"&gt;&lt;img src="' + img[5].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[6].src + '"&gt;&lt;img src="' + img[6].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[7].src + '"&gt;&lt;img src="' + img[7].src + '" /&gt;&lt;/a&gt;';
          else if (img.length &gt;= 1) imgtag = '&lt;a href="' + y + '"&gt;&lt;img src="' + img[0].src + '" style="max-width:100%;" alt="' + x + '" /&gt;&lt;/a&gt;';
          else imgtag = '&lt;div class="no-img"/&gt;';
      }
  }
  </code></pre>
  
  <p>This is the code I have been using to fetch images from inside the post in the form of a gallery which contains at least 12 images.</p>
  
  <p>But it's showing only one images in result</p>
  
  <pre><code>&lt;a href="http://3.bp.blogspot.com/-J3qrDYeQH4U/U-rj0I955_I/AAAAAAAAG7E/ZLvcdGFVVRc/s1600/12.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-J3qrDYeQH4U/U-rj0I955_I/AAAAAAAAG7E/ZLvcdGFVVRc/s1600/12.jpg" height="213" width="320"&gt;&lt;/a&gt;
  </code></pre>
  
  <p>But I want to get 12 images in a row like this and also want to simplify the "if" and "else if" part of code using "i array"</p>
  
  <pre><code>else if (img.length &gt;=8) imgtag = '&lt;a class="featured_gallery" href="' + img[0].src + '"&gt;&lt;img src="' + img[0].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[1].src + '"&gt;&lt;img src="' + img[1].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[2].src + '"&gt;&lt;img src="' + img[2].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[3].src + '"&gt;&lt;img src="' + img[3].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[4].src + '"&gt;&lt;img src="' + img[4].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[5].src + '"&gt;&lt;img src="' + img[5].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[6].src + '"&gt;&lt;img src="' + img[6].src + '" /&gt;&lt;/a&gt;&lt;a class="featured_gallery" href="' + img[7].src + '"&gt;&lt;img src="' + img[7].src + '" /&gt;&lt;/a&gt;';
  </code></pre>
  
  <p>can anyone best in javascript can help me to solve this issue.</p>
  
  <p>I want this strictly in javascript only</p>