function getStyle(Selector, Property, Value, StyleSheetIndex) {
var Selectors = document.styleSheets[StyleSheetIndex].rules;
for (var i = 0; i < Selectors.length; i++) {
if (Selectors[i].selectorText == Selector) {
alert(Value + " " + Property);
Selectors[i].style[Property] = "url(" + Value + ")";
}
}
}
Where Selector = “body”, Property=”backgroundImage”, value=”/images/bg.jpg”,StyleSheetIndex = 2,
but here the property value is not changing.Can anyone tell me why?
Since you have tagged
jQueryto this question I would suggest you to go simple using jQuery. Try this.As a side note since this method sets the style it should be named as
setStyleinstead ofgetStyle.