Le 5/14/09 7:10 PM, s k2999999 a écrit :
var o = {};
o.test = 'hahaha';
or :
var test = 'hahaha';
o.test = test;
Part(s) of object can be create at any time :
Not "parts", *properties*.
o.shchmilbick = o.test;
alert(o.shchmilbick);
Example:
JS:
function setPart(id, part, value) {
document.getElementById(id)[part] = value;
If the value of part is a DOM property name equivalent to a valid HTML
attribute name, that is OK, but do not use it to set other
properties.
}
HTML:
<button
onclick="setPart('test', 'test', 'hohoho');
alert(document.getElementById('test').test)">
A better example would use a valid property, say className (which maps
to the HTML class attribute):
onclick="setPart('test', 'className', 'hohoho');
alert(document.getElementById('test').className)">