Blogger Information
Blog 37
fans 0
comment 0
visits 21079
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
前端第十三课:javascript基础2-PHP培训九期线上班
渡劫小能手
Original
451 people have browsed it

对象

定义对象

  1. var obj = new Object();
  2. obj.name="bo";
  3. obj.age = "18";
  4. obj.abb = function(){
  5. console.log('我说话');
  6. };
  7. obj.abb();
  1. var obj = {name: "bo", age: "18"};
  2. obj.addr = "shen zhen";
  3. obj.speak = function(str){
  4. console.log('我会说话了【'+str+'】');
  5. }
  6. obj.speak('hello js object');
  1. var obj = {
  2. name:"bo",
  3. age:18,
  4. speek:function(str,str2){
  5. console.log('我说话了: '+str);
  6. console.log('str2='+str2);
  7. },
  8. speek2:function(){
  9. this.speek('speek2 调用了speek','aa');
  10. }
  11. }
  12. obj.speek2();

定时器

setTimeout()

只执行一次延时

  1. setTimeout(function () {
  2. console.log('页面加载');
  3. }, 3000);

setInterval()

一直执行,使用 clearInterval() 结束

  1. var haak = setInterval(function(){
  2. console.log('this is setInterval()');
  3. clearInterval(haak);
  4. },1000);

倒计时

  1. function send(){
  2. var flag=10;
  3. var txt = document.getElementById('btn').textContent;
  4. var timer = setInterval(function(){
  5. document.getElementById('btn').textContent = flag+'秒后重试';
  6. flag--;
  7. if(flag==0){
  8. document.getElementById('btn').textContent = txt;
  9. clearInterval(timer);
  10. }
  11. },1000);
  12. }
Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post