Print Var in JsFiddle

后端 未结 12 1637
眼角桃花
眼角桃花 2020-11-30 16:18

How would I print something to the result screen in JsFiddle from my JavaScript. I can\'t use document.write(), it doesn\'t allow it, neither print

12条回答
  •  臣服心动
    2020-11-30 16:34

    I have a template for this purpose; here is the code I use:

    HTML

    
    

    JavaScript

    function out()
    {
        var args = Array.prototype.slice.call(arguments, 0);
        document.getElementById('output').innerHTML += args.join(" ") + "\n";
    }
    

    Sample use (JavaScript)

    out("Hello world!");
    out("Your lottery numbers are:", Math.random(), 999, Math.PI);
    out("Today is", new Date());
    

提交回复
热议问题