小编leo*_*neo的帖子

Javascript:console.log到html

我想将console.log输出写入div层.

例如:

document.write(console.log(5+1)); //Incorrect, random example
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决问题吗?

谢谢.

编辑:

我的意思是,例如:

console.log("hi");
Run Code Online (Sandbox Code Playgroud)

它在屏幕上显示输出"hi".

注意:一个例子:http://labs.codecademy.com/#:workspace

javascript

53
推荐指数
5
解决办法
8万
查看次数

Javascript方法定义失败

我不明白我错了.我正在使用javascript.

编辑:我意识到在现代浏览器中有一个javascript控制台,所以我为造成的麻烦道歉.

var name = ""
function makelayer(name){
  var myLayer = document.createElement('div');
  myLayer.id = name;
  myLayer.style.position = 'absolute';
}
function position(x,y){
  myLayer.id = name;
  myLayer.style.left= x + "px";
  myLayer.style.top = y+ "px";
}
function size(w,h){
  myLayer.id = name;
  myLayer.style.width = w +'px';
  myLayer.style.height = h+'px';
}
function display(type){
  myLayer.id = name;
  myLayer.style.display = type;
}
function add(){
  myLayer.id = name;
  myLayer.innerHTML = '<img src="stickmanbackground.png" />'
  myLayer.style.zIndex = 99;
  myLayer.style.filter = 'alpha(opacity = 100)';
  document.body.appendChild(myLayer);
}
makelayer("name");
position(0,0);
size(500,500);
display("block");
add(); …
Run Code Online (Sandbox Code Playgroud)

javascript

1
推荐指数
1
解决办法
66
查看次数

标签 统计

javascript ×2