i am trying to place array into innerHTML but add a newline after each element,
var ingr_list = [];
//then i push some items
if (checkBox.checked == true){
text.style.display = "none";
ingr_list.push(nameofingredient);
document.getElementById('ingredienttype').innerHTML = ingr_list;
As for now it just show array as entire line which ruins my responsiveness (the longer the array gets the wider screen grow which i do not know how to fix - \n or would do the trick)
Join the array elements with <br> tags like this:
var output = ingr_list.join('<br>');
document.getElementById('ingredienttype').innerHTML = output;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With