Pages

Accessing attributes

Consider HTML :
    
         <a id="techblog" href="http://netdweb.blogspot.com/">NetdWeb</a>



getAttribute is used to access the href attribute from the <a> element .      
   
          var elementvar = document.getElementById("techblog");
          var hrefattrib= techblog.href;



setAttribute method is used to set the value of attributes e.g.
  
               var elementvar = document.getElementById("techblog");
               elementvar.setAttribute("href", "http://netdweb.blogspot.com/");