[Racine des codes] [Page précédente]

DOM - Modif Attribute

/Html JavaSript/DOM - Modif Attribute.js

// Pb de compatibilité / support de standard...
// voir http://www.xs4all.nl/~ppk/js/version5.html

Node.className = 'myclass'; // Mozilla & IE
Node.style.backgroundColor = 'lightgrey'; // Mozilla & IE

//---- setAttribute // Level 1 Core -------------------------------------------
// http://www.zvon.org/xxl/DOM1reference/Output/refs/interface_Element.html
Node.setAttribute('align', 'left')


// (!) pb with style :
Node.setAttribute('style', 'background-color:lightgrey;'); // Mozilla
Node.style.setAttribute('backgroundColor', 'lightgrey'); // IE
// instand use :
Node.style.backgroundColor = 'lightgrey'; // Mozilla & IE


//---- setProperty // Level 2 CSS ---------------------------------------------
Node.style.setProperty("background-color", "green", "important"); // Mozilla
[edit]