How can I print the all elements from the array to my main window in the browser and how can i add css code inside the java script?
const arr=["example1" , " example2 " , "example3"]
for (let i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
How can I print the all elements from the array to my main window in the browser and how can i add css code inside the java script?
const arr=["example1" , " example2 " , "example3"]
for (let i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
Check the code, and if you want a different class for each element you can use: element.innerHTML += '<p class="style'+i+'">'+arr[i]+'</p>';
const arr=["example1" , " example2 " , "example3"]
const element = document.getElementById("data");
for (let i = 0; i < arr.length; i++) {
element.innerHTML += '<p class="style">'+arr[i]+'</p>' ;
}
.style {
color: red;
}
<div id="data">
</div>