topical media & game development

talk show tell print

#javascript-code-20-attr.js / js



  // Set the class for the first <h1> Element
  attr( tag(“h1”)[0], “class”, “header” );
  
  // Set the value for each <input> element
  var input = tag(“input”);
  for ( var i = 0; i < input.length; i++ ) {
      attr( input[i], “value”, “” );
  }
  
  // Add a border to the <input> Element that has a name of ‘invalid’
  var input = tag(“input”);
  for ( var i = 0; i < input.length; i++ ) {
      if ( attr( input[i], “name” ) == ‘invalid’ ) {
          input[i].style.border = “2px solid red”;
      }
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.