Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:原生代码,写得不错
创建对象
<script type="text/javascript">
//创建对象 方法1:
var obj=new Object();
obj.name="张三";
obj.age="18";
obj.shuohua=function(){
console.log('我会说话');
}
//创建对象 方法2:
var obj2={
name:"李四",
age:"20",
shuohua:function(){
console.log('我说话');
}
}
console.log(obj2);
</script>
传参
<script type="text/javascript">
var obj={
name:"李四",
age:"20",
shuohua:function(str){
console.log('我说话了:'+ str);
}
}
obj.shuohua('你好,js对象')
</script>
定时器小案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<button id="btn" onclick="send()" type="button">发送验证码</button>
<script type="text/javascript">
function send(){
var flag=10;
var txt=document.getElementById('btn').textContent;
var tem = setInterval(function(){
document.getElementById('btn').textContent = flag + '秒后重试';
document.getElementById("btn").disabled=true;
flag--;
if(flag==0){
clearInterval(tem);
document.getElementById("btn").disabled=false;
document.getElementById('btn').textContent =txt
}
},1000)
}
</script>
</body>
</html>