Print new line in the source-code with jQuery.

Posted by Kucebe on Stack Overflow See other posts from Stack Overflow or by Kucebe
Published on 2010-04-26T21:44:25Z Indexed on 2010/04/26 21:53 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript