This is my script:
<script>
/*jslint browser:true */
var i;
var out = document.getElementById("output");
var args = ["aaa", "bbb", "ccc", "ddd", 1, 2, 4 + 4];
function displayArgs() {
"use strict";
for (i = 0; i < args.length; i++) {
out.appendChild(document.createTextNode(args[i] + "<br>"));
}
}
displayArgs(args);
</script>
my output so far all appears on a single line with the break tags showing rather than b
document.createTextNode
prevents text from being rendered as html.
Try this instead.
/*jslint browser:true */
var i;
var out = document.getElementById("output");
var args = ["aaa", "bbb", "ccc", "ddd", 1, 2, 4 + 4];
function displayArgs() {
"use strict";
for (i = 0; i < args.length; i++) {
out.appendChild(document.createTextNode(args[i]));
out.appendChild(document.createElement("br"));
}
}
displayArgs(args);
Demo: http://jsfiddle.net/LVm9z/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With