I have a simple function in jQuery that creates new elements in the DOM. the problem is in the html source code, it append every element in the same line, and it's very bad to read.
function _loadNewElements(elements){
for(var i=0; i<elements.length; i++){
var fixedElement = $('<img />')
var position = elements[i].position;
var cssMap = {
'position': 'fixed',
'top': position.top + "px",
'left': position.left + "px"
};
fixedElement.css(cssMap);
fixedElement.addClass("fixedTag");
fixedElement.attr('alt', elements[i].text);
fixedElement.attr('src', "elements/" + elements[i].id + ".png");
fixedElement.appendTo($('#board'));
//i'd like to print something here like ("\n");
}
}
I tried document.write("\n")
but in this context it doesn't work.
Any solution?