i have an array like:
var totalNum = new Array('img', 'img', 'img', 'img');
now on the documentready i added a div in the html page like:
$('#mainid').after('<div id="button"></div>');
the problem is i want to add <span></span> tags with total numbers in totalNum array like:
<div id="button">
<span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
</div>
i tried with for(){} loop into the .after() but got the syntax error. My code is here:
jQuery('#mainid').after('<div id="button">' +
for(i=1;i<=totalNum.length;i++){
jQuery('<span>'+i+'</span>').appendTo('#button');
}
+ '</div>');