JavaScript function arguments statements -
my problem is: (only example, must not make sense overall):
// make function , pass part of statement argument function examplefunction( argument ) { document.getelementbyid('testid')[0].style.argument = '#f00'; } // later onload examplefunction( background );
i found out doesn't work way, can't find out how right. if correct example send me on way happy , thankful.
firstly document.getelementbyid
returns single element (or null if no element found), not [0]
. secondly if want reference property dynamically use []
notation
// make function , pass part of statement argument function examplefunction( argument ) { document.getelementbyid('testid').style[argument] = '#f00'; } // later onload examplefunction( 'background' );
Comments
Post a Comment