老师,这个判断条件
for(var i=0;i<=arr3.length;i++)
如果用这个,最后面就会有一个undefined。
要是用
for(var i=0;arr3[i]!=undefined;i++)
就不会有后面的undefined
这个是为什么
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>非IE浏览器事件</title> <style> .div1{width:200px;height: 200px;background-color: blue} .div2{width: 100px;height: 100px;background-color: pink;margin: 25px auto} </style> </head> <body> <div class="div1">div1 <div class="div2">div2</div> </div> <script> document .querySelector('.div1').attachEvent('onclick',function () { console .log('这是div1'); }) </script> </body> </html>
老师为什么我这个attachEvent会报错?
唉呀妈呀 ,老师直接上网址啊 感谢老师 那我只记住该记住的就行了
【getattribute setattribute removeattribute】跟【setproperty getproperty removeproperty】有啥区别 ?谢谢老师
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> div{ width: 20px; height: 20px; border: 1px solid black; position: absolute; } </style> </head> <body> <input type="range" min="0" max="100" value="50"> <div></div> <script> var input=document.querySelector("input"); var div=document.querySelector("div"); input.onmounsemove=function () { console.log("(x,y):("+event.clientX+","+event.clientY+")"); } </script> </body> </html>
本视频6分57秒,我的代码和老师一摸一样但是出不来效果,“event”这个单词显示有删除线,不知道是什么意思,是因为这个显示不出效果吗?怎样才能没有删除线
老师,我这个浏览器总是报错,我不知道哪里写错了。
<style> #div1{ background:red; width:100px; height:100px; } #div2{ background:green; width:50px; height:50px; } </style> <body> <div id="div1" > <div id="div2" > </div></div> <script> var div1=document.querySelector('#div1') var div2=document.querySelector('#div2') function test(){ console.log("文本3") } div2.attachEvent('onclick',test); div2.attachEvent("onclick",function(){ console.log("文本1") }) </script> </body>
老师,这里把移除代码写在前面,为什么函数还会执行一遍?我理解代码是自上而下执行,不会打印出才对,当div2移除成功,为什么点击div2部分,div1函数还会执行呢?我的理解是移除后点击div2部分div1不会执行。
<style> #div1{ background:red; width:100px; height:100px; } #div2{ background:green; width:50px; height:50px; } </style> <body> <div id="div1" onclick="te()">eee <div id="div2" onclick="te2();te3()">wen </div> </div> <span>wen</span> <script> var div1=document.querySelector('#div1') var div2=document.querySelector('#div2') function te(){ console.log("文本") } function te2(){ div2.setAttribute("onclick","null"); console.log("文本2"); } function te3(){ div2.setAttribute("onclick","null"); console.log("文本3"); } </script> </body>
老师,这里是因为这个函数为监听事件,决定了这个是事件捕获吗?除了这个自下而上的效果上区分,还可以怎么区分哪些算是事件捕获,哪些算是冒泡事件。
老师,这里说的集合可用数组方式使用,是指数组的所有属性都适用于集合吗?
老师,这样写m.puth(m[0]),为什么报错呢?
<script> var t=document.title; var m=t.split(""); console.log(m); m.puth(m[0]); console.log(m); </script>
老师,我不明白为什么title的类型为字符串呢,其他的都为对象。
<div id="d" style="width: 100px;height: 100px;background: red">文本</div>
<script> var t=document.getElementById("d"); console.log(typeof(t)); console.log(typeof(document.title)); console.log(typeof(document.head)); console.log(typeof(document.body)); </script>
老师,我看这个视频下面的回答,为什么我这么写会报错呢。如果写var t=s(); t 就不会不报错。是和咱们这个这个函数作为函数的返回值有关吗?
<script> function s(){ console.log("文本"); } var t=s(); t(); </script>
老师,如果这样写,console.log(console.log("文本")) console.log(a());这两种写法有问题吗? a()表示调用这个函数了,结果是“文本”,在写这个console.loga(a()) ,就表示打印“文本”,为什么是结果运行了两遍。一遍为文本,一遍为unfined。我不知道哪里错了。
<script> var a=function( ){ console.log("文本") } console.log(a); console.log(a()); console.log(console.log("文本")) </script>
老师,这里将函数赋值给a ,那么a不应是“这是一顿饭”吗?为什么是整个函数呢。是因为没有写函数名吗?但是函数b为什么就显示了“这是一顿饭”了。
<script> var a=function(){ console.log("这是一顿饭") } console.log(a); function b( f){ f } b(a()); </script>
老师,这里用到返回值的时候,为什么没有写调用func()这个函数这一代码,而且写在了这个函数{}之外呢。
function info(){ console.log('我是XXX'); console.log('我会唱歌'); function func(){ console.log('开始表演'); } return func; } var a=info(); a();
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637