I have a text file populated dynamically from another javascript. Owing to require/bundle issues and many, many other problems I am just writing the results to a text file.
I now want to display the results in a paragraph on the webpage. Accessing the info seems straightforward enough, printing to the console works with the below, but how do I now put the text in a paragraph so I can format it with CSS etc:
The text file contains:
let text = 'Some random text';
And then html file has this in it:
</head>
<body>
<h1>Wallboard</h1>
<script src=output.txt></script>
<script>
let pageText = text;
console.log(pageText)
let myParagraph = document.querySelector("#pageText");
console.log(myParagraph)
myParagraph.innerHTML = pageText;
;
</script>
<p id="pageText"></p>
</body>
</html>
You will have to find the HTML element with JavaScript and then set the elements inner HTML to be your text content: