function callBack(data1, predicted_label){
const resultParagraph = document.getElementById("resultParagraph");
resultParagraph.textContent = `Sentiment: ${predicted_label}`;
const historyList = document.getElementById("historyList");
const listItem = document.createElement('li');
listItem.textContent = `Text: ${data1} Sentiment: ${predicted_label}`;
historyList.prepend(listItem); }
In this code i want to add a new line between Text: ${data1} Sentiment: ${predicted_label}
.
I’ve tried adding n
, tried adding a <br>
tag but nothing seems to work
2
Answers
HTML rendering doesn’t respect newlines – you’ll need to use innerHTML instead of textContent and add a
<br>
tag where you want the line breakYou can use CSS to style the list item to display "Text" and "Sentiment" on separate lines.