Print Var in JsFiddle

2019-01-09 21:04发布

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.

What should I use?

12条回答
劳资没心,怎么记你
2楼-- · 2019-01-09 21:40

Use the alert() function:

alert(variable name);
alert("Hello World");
查看更多
疯言疯语
3楼-- · 2019-01-09 21:45

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

$('body').append(yourVariable); 
查看更多
爷、活的狠高调
4楼-- · 2019-01-09 21:47

To be able to see output from console.log() in JSFiddle, go to External Resources on the left-side panel and add the following link for Firebug:

https://getfirebug.com/firebug-lite-debug.js

Example of the result after adding firebug-lite-debug.js

查看更多
神经病院院长
5楼-- · 2019-01-09 21:47

Might not do what you do, but you can type

console.log(string)

And it will print the string into the console of your browser. In chrome push CTRL + SHIFT + J to open the console.

查看更多
爷的心禁止访问
6楼-- · 2019-01-09 21:48

Try:

document.getElementById('element').innerHTML = ...;

Fiddle: http://jsfiddle.net/HKhw8/

查看更多
Summer. ? 凉城
7楼-- · 2019-01-09 21:48

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

查看更多
登录 后发表回答