cachaito
12/14/2013 - 12:20 AM

Definiowanie atrybutów elementu html

var element = document.getElementsByTagName('INPUT')[0];
    element.setAttribute('type','button');
    element.removeAttribute('id'); //usuwa atrybut i zawartość
    element.removeAttribute[7]; //usuwa zawartość atrybutu
    element.attributes[0].name //Returns the name of an attribute
    element.attributes[0].value //Sets or returns the value of the attribute
    element.attributes[0].isId //Returns true if the attribute is of type Id, otherwise it returns false - nie działa w IE i Opera
    element.attributes[0].specified //Returns true if the attribute has been specified, otherwise it returns false
    
    element.getAttribute('style')
    element.getAttributeNode('style');
    element.style.getPropertyValue('font-family'); //nie działa w IE < 9 -->