Changing backgroun-image dinamically
I get the current one by
att = getComputedStyle(obj,'').getPropertyValue('background-image');
the name of the image has a number in it. I replace just the number by
var newatt = att.replace(new RegExp( "([0-9])", "gi" ),counter);
alert(newatt); gives me the correct new name
getComputedStyle(obj,'').setProperty('background-image', newatt, 0);
results in nothing to change.....
may I get some help, please?
The getComputedStyle() method returns an object of type CSSStyleDeclaration.
While that object does have the .setProperty() method, the .getComputedStyle() method returns only a read-only interface to that object, according to Mozilla. Therefore only "get" (read) methods work, not "set" (write) methods.
Last edited by mavigozler; 07-16-2012 at 03:24 AM.
thanks. Looks too complicated for me.
I used jQuery instead and just one line of code made the job!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)