I need to add 3 paragraphs tags here straight from the script that prints The same thing that logs on the console
<script >
var array= [1,2,4];
$.each(array,function (index,value) {
console.log(index + ": "+value)
});
</script>
Use this Demo Here
<script>
var array= [1,2,4];
$.each(array,function (index,value) {
$('<p>').appendTo('body').html(index + ": "+value);
})
</script>
May be it will help you.
var array= [1,2,4]; $.each(array,function(index,value){ $('<p />').appendTo('#apd').html(index + ": "+value); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id='apd'></div>
Try this..
<body>
<div id="data"></div>
</body>
<script>
var test="";
var array= [1,2,4];
for (i = 0; i < array.length; i++) {
test += '<p>'+i+ ':'+array[i]+'</p>';
}
document.getElementById("data").innerHTML = test;
</script>
Output:
0:1
1:2
2:4
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.