关于this的问题
来源:3-8 选择题
你上b站不
2019-03-23 11:28:32
<!DOYHTML>
<html>
<head>
<title>DOM-onload</title>
<style>
</style>
</head>
<body onload="test(this)" id="body">
<script type="text/javascript">
function test(obj){
alert("hello");
alert(obj); //为什么加载时打印的会是window对象?不应该是body吗?
}
</script>
</body>
</html>1回答
好帮手慕阿满
2019-03-24
同学你好,Window 对象表示浏览器中打开的窗口,body是浏览器的主体,所以会返回window对象。
如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~
相似问题