<script type="text/javascript">
function evenNumbers() {
var i;
for (i=0;i<=20;i++) {
if (i%2==0) {
document.write(i+"\n");
}
}
}
</script>
I am trying to print the number using the \n escape sequence but it is not working. Can anyone please help.
Note: I don’t want to use <br/> tag and also i have tried /\n/ and /\r/. But it is not working.
A simple line break doesn’t mean anything in HTML, it’s simply whitespace.
Either print everything inside a
<pre>tag, which preserves whitespace formatting, or use HTML tags like<br>,<li>or whatever else is appropriate.