I'm creating a website that loads content from a db through an ajax call and then writes the data by creating elements and appending them to their parent.
It is currently not working correctly as can be seen in the images below, but when I manually add the HTML using the developer tools, everything works fine.
This is how it should appear,

This is how it currently appears,

What am I doing wrong?
( jsFiddle )
var thumbsDIV = document.createElement('div');
thumbsDIV.className = 'Thumbs';
for (var i = 0; i < this.pictures.length; i++) {
var pictureID = this.pictures[i].pictureID;
var thumbDIV = document.createElement('div');
thumbDIV.className = 'Thumb';
var thumbIMG = document.createElement('img');
thumbIMG.id = 'Review_' + this.iD + '_Picture_' + this.pictures[i].pictureID;
thumbIMG.src = this.pictures[i].picture;
thumbIMG.border = '0';
thumbDIV.appendChild(thumbIMG);
thumbsDIV.appendChild(thumbDIV);
}
picturesDIV.appendChild(thumbsDIV);
parentDIV.appendChild(picturesDIV);
.Thumb {
display: inline-block;
margin-bottom: 5px;
width: 15%;
cursor: hand;
cursor: pointer;
zoom: 1;
*display: inline;
}
.Thumbs:after {
content: "";
width: 100%;
display: inline-block;
zoom: 1;
*display: inline;
}
.Thumb img {
width: 100%;
}
<div class="Thumbs">
<div class="Thumb" onClick="ViewThumb(1,1)">
<img src="http://smakelynn.com/images/pictures/pic2.png" id="Review_1_Picture_1" border="0" title="Voorgerecht">
</div>
<div class="Thumb" onClick="ViewThumb(1,2)">
<img src="http://smakelynn.com/images/pictures/pic1.png" id="Review_1_Picture_2" border="0" title="Hoofdgerecht">
</div>
<div class="Thumb" onClick="ViewThumb(1,3)">
<img src="http://smakelynn.com/images/pictures/pic3.png" id="Review_1_Picture_3" border="0" title="Dessert">
</div>
<div class="Thumb" onClick="ViewThumb(1,4)">
<img src="http://smakelynn.com/images/pictures/pic4.png" id="Review_1_Picture_4" border="0" title="Tafeldekking">
</div>
<div class="Thumb" onClick="ViewThumb(1,5)">
<img src="http://smakelynn.com/images/pictures/pic5.png" id="Review_1_Picture_5" border="0" title="Sfeerbeeld">
</div>
</div>
content:to go after.Thumbsand not.Thumb? Or is that a typo?content:works for me after JS. One difference in your layout is that you no longer have a whitespace text node after every.Thumbelement. Also, youronclickis going to fail to give the desired result, but that's a different issue.