Home » Jquery » jquery – How do I take an item from an javascript array and transfer it to html in a paragraph tag?-Exceptionshub

jquery – How do I take an item from an javascript array and transfer it to html in a paragraph tag?-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I have an JS array panier=["Crayon Crayola"] and I want to put the item inside it into a paragraph tag <p>Crayon Crayola</p>. So how can I do this?

How to&Answer:

if you have only one element in the array then you can use this(you need to give the p tag an id):

document.getElementById("p1").innerHTML = panier[0];

if you want the whole array then use:

document.getElementById("p1").innerHTML = panier.toString();