I have these two arrays:
var numbers = ['one', 'two', 'three'];
var colors = ['blue', 'red', 'white'];
Now I want this output:
$('.classname').html("<span id = 'one'>blue</span><span id = 'two'>red</span><span id = 'three'>white</span>");
How can I do that?
I can use join and mix second array with <span> but I cannot add id={arr1-values}:
$('.classname').html('<span>' + colors.join('</span><span>') + '</span>');
appendChild()but not append, I want replace, likehtml()?html(), it's one of the few jQuery methods that replaces the content.