87,907
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>匿名函数</title>
<style>
#div1 {
width: 100px;
height: 100px;
background-color: black;
color: white;
}
</style>
</head>
<script>
window.onload = function() {
var avc = document.getElementById("div1");
document.write(avc);
}
var a = function() {
alert("好困呐!!!!!!!!");
}
a();
</script>
<body>
<div id="div1">搜狗拼音输入法</div>
</body>
</html>
const obj = {a:1,b:2};
console.log(obj);//这时候可以看到完整的obj的内容
console.log('obj:'+obj);//这时候你看到的是:obj:[object Object]
/*
和你"看到的[object HTMLDivElement]"一样。
它的原因是。你这时候看到的是对象toString以后的结果。简单的说,你看到的是这个对象的数据类型,而不是你想像中的数据本身
不管你是document.write或者是alert。想看到结果。要么是值类型,要么是指定对象的某个方法或属性,又或者借助某个额外的方法
上面很多朋友建议你使用开发者工具了。比如:Chrome开发者工具。在Element中选中一个元素后,右边【properties】选项卡中可以查看到当前元素所有可用的方法和属性
*/
//或者你也可以简单的打印出来
for(const key in avc){
console.log(key+':'+typeof avc[key])
}