javaScript点击更改内容

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
</head>
<body>
<div id='frm'>
 <input type="button" name="input" value="按钮" />
  <input type="button" name="input" value="按钮" />
 <input type="button" name="input" value="按钮" />
  <input type="button" name="input" value="按钮" />
   <input type="button" name="input" value="按钮" />
</div>
<script type="text/javascript">
var frm = document.getElementById('frm');
var inputs = frm.getElementsByTagName('input');
var tmpInput = [];
for(var i=0;i<inputs.length;i++){
    if(inputs[i].type==='button'){
        inputs[i].value='按钮'+i;
        inputs[i].myI = i;
        inputs[i].onclick = (function(x){
           return(function(){
                while(tmpInput.length>0){
                    var tmp = tmpInput.pop();
                    tmp.value = '按钮'+tmp.myI;
                }
                inputs[x].value='已点';
                tmpInput.push(inputs[x]);
            });
        })(i)
    }
}
</script>
</body>
</html>

上一篇:TensorFlow|基于Transformer的自然语言推理(SNLI)


下一篇:tensorflow搭建cnn人脸识别训练+识别代码(python)