Print Var in JsFiddle

后端 未结 12 1593
眼角桃花
眼角桃花 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:38

    document.body.innerHTML = "Your data";

    0 讨论(0)
  • 2020-11-30 16:42

    Use the alert() function:

    alert(variable name);
    alert("Hello World");
    
    0 讨论(0)
  • 2020-11-30 16:43

    Here's one alternative: http://jsfiddle.net/skibulk/erh7m9og/1/

    document.write = function (str) {
        document.body.insertAdjacentHTML("beforeend", str);
    }
    
    document.write("¡hola mundo");
    
    0 讨论(0)
  • 2020-11-30 16:49

    With ES6 tricks could be

    function say(...args)
    { 
        document.querySelector('#out').innerHTML += args.join("</br>");
    }
    say("hi","john");
    

    Add only

     <span id="out"></span>
    

    in HTML

    0 讨论(0)
  • 2020-11-30 16:53

    You can do this ---> http://jsfiddle.net/chY5y/

    $('body').append(yourVariable); 
    
    0 讨论(0)
  • 2020-11-30 16:58

    Now jsfiddle can do it from the scratch. Just go to Javascrpt --> Frameworks & extensions --> Jquery(edge) and check Firebug lite checkbox

    0 讨论(0)
提交回复
热议问题