OK.
I have made a function here that will suposedly go down the stylesheet and change particular properties. However I want to be able to make the property name defined when the function is called.
Function:
[CODE=javascript]
function changeRule(theN umber, property, value) {
var theRules = new Array();
if (document.style Sheets[0].cssRules) {
theRules = document.styleS heets[0].cssRules;
} else if (document.style Sheets[0].rules) {
theRules = document.styleS heets[0].rules;
}
theRules[theNumber].style.[property] = value;
}
[/CODE]
Basic Function call:
[CODE=javascript]
changeRule(1, 'backgroundImag e', 'url(./images/corner2.gif)');
[/CODE]
so basicly I want the "property" variable to apear as the propertyname. How can i do this? any other suggestions to improve this code?
I have made a function here that will suposedly go down the stylesheet and change particular properties. However I want to be able to make the property name defined when the function is called.
Function:
[CODE=javascript]
function changeRule(theN umber, property, value) {
var theRules = new Array();
if (document.style Sheets[0].cssRules) {
theRules = document.styleS heets[0].cssRules;
} else if (document.style Sheets[0].rules) {
theRules = document.styleS heets[0].rules;
}
theRules[theNumber].style.[property] = value;
}
[/CODE]
Basic Function call:
[CODE=javascript]
changeRule(1, 'backgroundImag e', 'url(./images/corner2.gif)');
[/CODE]
so basicly I want the "property" variable to apear as the propertyname. How can i do this? any other suggestions to improve this code?
Comment