Reputation: 113
I have created a chatbot program written in javascript. Whenever user hits enter, the response is coming in same line instead of going to new line. As advised I have added the code for loadresponse() too. Here is the snippet of the code:
// function to display success response in conversation div
function loadResponse(lexResponse) {
var conversationDiv = document.getElementById('conversation');
var responsePara = document.createElement("P");
responsePara.className = 'lexResponse';
if (lexResponse.message) {
responsePara.appendChild(document.createTextNode(lexResponse.message));
responsePara.appendChild(document.createElement('br'));
}
The messages are not appearing in new line instead appearing on same line
Upvotes: 1
Views: 182
Reputation: 1538
You can append the <br />
to the innerHTML
property.
responsePara.innerHTML = `${responsePara.innerHTML}<br />`;
Upvotes: 2