javascript - How to show console output on webpage? -
When I go to websites like codecademy or JSBin, I have notice that they allow you to see console output. how does it work?
Just to clarify, let's assume that a user typed it in a text box
console.log ('hello');
How do I create output on the actual web page and not just the browser's console?
As Shahar has mentioned, the way to see output on the actual web page is in a DOM object For example, if we create a single output for output and make it output using jQuery:
HTML:
& lt; Div id = "output" & gt; & Lt; Div & gt;
Javascript using JavaScript:
// Your example output is var string = "Hello"; // Add output at the end of the output function () ($ ('# output'). Append (string + "
& lt; br / & gt;);}
above Example output will be output code in string
and line break whenever whenever the outputToPage ()
function is called. Please note that you can use jQuery's .append ( )
To work, jQuery needs to be loaded.
Comments
Post a Comment