Search code examples
jqueryarraysappendto

Jquery array appendTo through function


Trying to append array values to divs, this part works , nothing wrong here, but i need the array values to be formatted and it would be simple and neat to just pass the value through a function right before the appendTo() jquery function, dont know if this is possible though...

have a long list of this: $(c[3]).appendTo('#output_div_id1');

what im trying to achieve is $( number_format(c[3])).appendTo('#div');

This does not seem to be working. Ideas how i could achieve this?


Solution

  • Or just use append(). http://api.jquery.com/append/

    Example:

    <div id="element">Hello</div>
    $('#element').append(function(index, html) {
        return ' world!';
    });