SOURCE

console 命令行工具 X clear

                    
>
console
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
  var input = inputs[i];
  if(input.type !== 'text') {
    continue;
  }
  input.onfocus = function() {
    for(var i = 0; i < inputs.length; i++) {
      var input = inputs[i];
      if (input.type !== 'text') {
        continue;
      }
    input.stlye.backgroundColor = '';
  }
    this.style.backgroundColor = 'red';
}
}
<input type="text" /><br>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" /><br>
<input type="button" value="submit"/>