onblur





js/script.js
  • function funFocus1() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[1].style.border = '1px solid #F00';
  •  val.childNodes[1].style.backgroundColor = '#FFFFCC';
  • }
  •  
  • function funBlur1() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[1].style.border = '1px solid #808080';
  •  val.childNodes[1].style.backgroundColor = '#FFF';
  • }
  •  
  • function funFocus7() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[7].style.border = '1px solid #F00';
  •  val.childNodes[7].style.backgroundColor = '#FFFFCC';
  • }
  •  
  • function funBlur7() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[7].style.border = '1px solid #808080';
  •  val.childNodes[7].style.backgroundColor = '#FFF';
  • }
  •  
  • function funFocus13() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[13].style.border = '1px solid #F00';
  •  val.childNodes[13].style.backgroundColor = '#FFFFCC';
  • }
  •  
  • function funBlur13() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[13].style.border = '1px solid #808080';
  •  val.childNodes[13].style.backgroundColor = '#FFF';
  • }
  •  
  • window.onload = function() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[1].onfocus = funFocus1;
  •  val.childNodes[1].onblur = funBlur1;
  •  val.childNodes[7].onfocus = funFocus7;
  •  val.childNodes[7].onblur = funBlur7;
  •  val.childNodes[13].onfocus = funFocus13;
  •  val.childNodes[13].onblur = funBlur13;
  •  for(var i=0; i<val.childNodes.length; i++) {
  •   if(i%2 != 0) {
  •    val.childNodes[i].style.border = '1px solid #808080';
  •   }
  •  }
  • }
  • function funFocus1() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[1].style.border = '1px solid #F00';
  •  val.childNodes[1].style.backgroundColor = '#FFFFCC';
  • }
  •  
  • function funBlur1() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[1].style.border = '1px solid #808080';
  •  val.childNodes[1].style.backgroundColor = '#FFF';
  • }
  •  
  • function funFocus7() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[7].style.border = '1px solid #F00';
  •  val.childNodes[7].style.backgroundColor = '#FFFFCC';
  • }
  •  
  • function funBlur7() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[7].style.border = '1px solid #808080';
  •  val.childNodes[7].style.backgroundColor = '#FFF';
  • }
  •  
  • function funFocus13() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[13].style.border = '1px solid #F00';
  •  val.childNodes[13].style.backgroundColor = '#FFFFCC';
  • }
  •  
  • function funBlur13() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[13].style.border = '1px solid #808080';
  •  val.childNodes[13].style.backgroundColor = '#FFF';
  • }
  •  
  • window.onload = function() {
  •  var val = document.getElementById('d1');
  •  val.childNodes[1].onfocus = funFocus1;
  •  val.childNodes[1].onblur = funBlur1;
  •  val.childNodes[7].onfocus = funFocus7;
  •  val.childNodes[7].onblur = funBlur7;
  •  val.childNodes[13].onfocus = funFocus13;
  •  val.childNodes[13].onblur = funBlur13;
  •  for(var i=0; i<val.childNodes.length; i++) {
  •   if(i%2 != 0) {
  •    val.childNodes[i].style.border = '1px solid #808080';
  •   }
  •  }
  • }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <div id="d1">
  •   <input type="text" name="text1" />
  •   <br />
  •   <br />
  •   <input type="text" name="text2" />
  •   <br />
  •   <br />
  •   <input type="text" name="text3" />
  •  </div>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <div id="d1">
  •   <input type="text" name="text1" />
  •   <br />
  •   <br />
  •   <input type="text" name="text2" />
  •   <br />
  •   <br />
  •   <input type="text" name="text3" />
  •  </div>
  • </body>
  • </html>