mg4377娱乐娱城官网_mg4377娱乐手机版_www.mg4377.com

当前位置: mg4377娱乐娱城官网 > www.mg4377.com > 正文

目录下标之li集结绑定点击事件,li集合绑定点击

时间:2019-06-01 23:45来源:www.mg4377.com
上面壹段代码给大家介绍li集合绑确定地点击事件,具体代码如下所示: js 索引下标之li会集绑定点击事件,jsli 上边一段代码给大家介绍li集结绑定点击事件,具体代码如下所示: //

上面壹段代码给大家介绍li集合绑确定地点击事件,具体代码如下所示:

js 索引下标之li会集绑定点击事件,jsli

上边一段代码给大家介绍li集结绑定点击事件,具体代码如下所示:

//Method-1:
var items = document.getElementsByTagName('li');
  for(var i=0;i<items.length;i  ){
    items[i].index = i;
    items[i].onclick = function(){
      this.innerHTML = this.index;
  }
}
//Method-2:
var items = document.getElementsByTagName('li');
  for(var i = 0; i<items.length; i  ){
    (function(index){
      items[i].onclick = function(){
      this.innerHTML = index;
    }
  })(i)
}
//Method-3:
var items = document.getElementsByTagName('li');
for(var i = 0; i<items.length; i  ){
  items[i].onclick = function(index){
    return function(){
      this.innerHTML = index;
    }
  }(i)
}

总结

以上所述是作者给我们介绍的js 索引下标之li会集绑定点击事件,希望对大家有着扶助,若是大家有其余疑问请给本身留言,笔者会及时回复大家的。在此也特别多谢大家对帮客之家网址的支持!

www.mg4377.com, 索引下标之li集结绑定点击事件,jsli 上边壹段代码给咱们介绍li会集绑定点击事件,具体代码如下所示: //Method-1:var items = document.getEle...

//Method-1:
var items = document.getElementsByTagName('li');
  for(var i=0;i<items.length;i ){
    items[i].index = i;
    items[目录下标之li集结绑定点击事件,li集合绑定点击事件。i].onclick = function(){
      this.innerHTML = this.index;
  }
}

//Method-1:
var items = document.getElementsByTagName('li');
  for(var i=0;i<items.length;i ){
    items[i].index = i;
    items[i].onclick = function(){
      this.innerHTML = this.index;
  }
}

//Method-1:
var items = document.getElementsByTagName('li');
  for(var i=0;i<items.length;i  ){
    items[i].index = i;
    items[i].onclick = function(){
      this.innerHTML = this.index;
  }
}
//Method-2:
var items = document.getElementsByTagName('li');
  for(var i = 0; i<items.length; i  ){
    (function(index){
      items[i].onclick = function(){
      this.innerHTML = index;
    }
  })(i)
}
//Method-3:
var items = document.getElementsByTagName('li');
for(var i = 0; i<items.length; i  ){
  items[i].onclick = function(index){
    return function(){
      this.innerHTML = index;
    }
  }(i)
}

//Method-2:
var items = document.getElementsByTagName('li');
  for(var i = 0; i<items.length; i ){
    (function(index){
      items[i].onclick = function(){
      this.innerHTML = index;
    }
  })(i)
}

//Method-2:
var items = document.getElementsByTagName('li');
  for(var i = 0; i<items.length; i ){
    (function(index){
      items[i].onclick = function(){
      this.innerHTML = index;
    }
  })(i)
}

编辑:www.mg4377.com 本文来源:目录下标之li集结绑定点击事件,li集合绑定点击

关键词: