+ 5

How will i output a source code to show on the browser screen in html or JavaScript?

10th Aug 2019, 10:56 PM
Joseph Onipede
Joseph Onipede - avatar
2 Answers
+ 2
How do you mean? Display tags? Like: <div></div> but it's shown on the page and not as an element? For that use &lt; to make a < and &gt; to make a > so &lt;div&gt;&lt;/div&gt; would be <div></div>. I hope I explained that understandably 😅
10th Aug 2019, 11:59 PM
Paul Grasser
Paul Grasser - avatar
+ 1
One thing you can do is, put your entire JavaScript code in `Code here ` Then keep it as a variable Let code = `Code` To run it use : eval(code) To display: document.querySelector("#out").innerHTML = code; Here, 'out' must be the Id of a pre tag. Though you shouldn't use eval too often but still it is a method you can try
11th Aug 2019, 2:13 AM
RZK 022
RZK 022 - avatar