0
<body>
    <center>
    <input type="text" id="item">
    <button onclick="getItem()">Add to List</button> <br>
    <textarea readonly id="list"></textarea>
</body>

<script>
    function getItem() {
    document.getElementById("list").value += document.getElementById("item").value;
}
</script>

</html>

As you may be able to tell, I have created an "Item" textbox and a button that, when clicked, adds the content of said "Item" textbox to the "List" textarea.

What I want to know is how do I add a line break before it adds the item?

0

1 Answer 1

5
document.getElementById("list").value += "\n" + document.getElementById("item").value;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.