このように行えるのではないでしょうか?
HTML
1<!DOCTYPE HTML>
2<html lang="ja">
3<head>
4 <meta charset="UTF-8">
5 <title>タイトル</title>
6 <style type="text/css">
7 * {
8 margin: 0;
9 padding: 0;
10 }
11
12 .gallery-image {
13 bottom: 5px;
14 }
15
16 .gallery-image img {
17 width: 100px;
18 height: 100px;
19 overflow: hidden;
20 }
21 </style>
22</head>
23<body>
24<script>
25 for (i = 1; i <= 13; i++) {
26 document.write(
27 '<div class="gallery-image">' +
28 '<a href="https://placehold.jp/ff4747/ffffff/200x150.png?text=' + i + '">' +
29 '<img src="https://placehold.jp/ff4747/ffffff/200x150.png?text=' + i + '">' +
30 '</a>' +
31 '</div>'
32 );
33 }
34</script>
35</body>
36</html>
追記
innerHTMLの場合はこのように行えると思います。
HTML
1<!DOCTYPE HTML>
2<html lang="ja">
3<head>
4 <meta charset="UTF-8">
5 <title>タイトル</title>
6 <style type="text/css">
7 * {
8 margin: 0;
9 padding: 0;
10 }
11
12 .gallery-image {
13 bottom: 5px;
14 }
15
16 .gallery-image img {
17 width: 100px;
18 height: 100px;
19 overflow: hidden;
20 }
21 </style>
22</head>
23<body>
24<script>
25 document.addEventListener("DOMContentLoaded", function () {
26 for (i = 1; i <= 13; i++) {
27 document.body.innerHTML +=
28 '<div class="gallery-image">' +
29 '<a href="https://placehold.jp/ff4747/ffffff/200x150.png?text=' + i + '">' +
30 '<img src="https://placehold.jp/ff4747/ffffff/200x150.png?text=' + i + '">' +
31 '</a>' +
32 '</div>';
33 }
34 }, false);
35</script>
36</body>
37</html>
insertAdjacentHTMLを使うと以下のように行えると思います。
HTML
1<!DOCTYPE HTML>
2<html lang="ja">
3<head>
4 <meta charset="UTF-8">
5 <title>タイトル</title>
6 <style type="text/css">
7 * {
8 margin: 0;
9 padding: 0;
10 }
11
12 .gallery-image {
13 bottom: 5px;
14 }
15
16 .gallery-image img {
17 width: 100px;
18 height: 100px;
19 overflow: hidden;
20 }
21 </style>
22</head>
23<body>
24<script>
25 document.addEventListener("DOMContentLoaded", function () {
26 for (i = 1; i <= 13; i++) {
27 document.body.insertAdjacentHTML('beforeend',
28 '<div class="gallery-image">' +
29 '<a href="https://placehold.jp/ff4747/ffffff/200x150.png?text=' + i + '">' +
30 '<img src="https://placehold.jp/ff4747/ffffff/200x150.png?text=' + i + '">' +
31 '</a>' +
32 '</div>');
33 }
34 }, false);
35</script>
36</body>
37</html>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/21 17:03