最新回答 / 慕斯8234454
老师讲解是用 "titles.length" 做循环 (for(var i=0;i<titles.length;i++)),因此this 代表 titles
2017-05-05
最新回答 / you_belong_to_me
function $(id){ return typeof id==='string'?document.getElementsById(id):id; }$ 函数名。id 参数如果传入的id是字符串类型的。返回 document.getElementById(id)
2017-04-25
最新回答 / 慕斯8234454
定义标签id 不能用数字开头,但js 理获取循环的标签id 只是代表数组(标签有很多个,所以才要循环)中的第几个,并不是HTML 中代表标签的id
2017-04-12
最新回答 / startitunderground
<...code...>function getId(id){ return typeof id==="string"?document.getElementById(id):id; };window.addEventListener("load",function(){ //获取鼠标滑过或点击的标签和要切换的内容的元素 var navList=getId("nav").getElementsByTa...
2017-04-04
已采纳回答 / 薛定谔的量子猫
因为timer接收到的是setTimeout返回的一个整数类型的值,clearTimeout()是根据这个值去清除计时器,计时器清除后timer变量的值依旧不变,所以最好重新赋值为NULL;setInterval也是同样道理
2017-04-03
最赞回答 / 慕虎9030788
//封装ID //typeof 操作符来检测变量的数据类型 string=字符串 //函数作用:之后用到id选择器可以简写,判断传入的参数为字符串就返回 //$就是一个标示符。 也可以用getID等,如果你的页面中...
2017-03-24
最新回答 / 慕斯8234454
如果注釋,後面的 divs[this.id].style.display='block' ;會出現錯誤, 因this.id代表 "titles[i].id",不然要再for 循環divs.length一次.
2017-03-22