Page 1 of 1
Set src of a childNode?
Posted: Tue May 31, 2011 3:18 pm
by unemployment
My last childnode is an img and is undefined according to firebug.
Can I do this?
this.parentNode.parentNode.parentNode.parentNode.previousSibling.childNodes.childNodes.src = "/assets/img/icons/process.png";
Re: Set src of a childNode?
Posted: Tue May 31, 2011 4:38 pm
by jacek
It would probably be easier to access the element you want by giving it an ID and using getElementById
would that be possible ?
Re: Set src of a childNode?
Posted: Tue May 31, 2011 4:48 pm
by unemployment
jacek wrote:It would probably be easier to access the element you want by giving it an ID and using getElementById
would that be possible ?
Unfortunately that is not possible since the element is in a dynamic array
Re: Set src of a childNode?
Posted: Tue May 31, 2011 6:47 pm
by unemployment
fixed... yay
Re: Set src of a childNode?
Posted: Tue May 31, 2011 8:39 pm
by jacek
unemployment wrote:fixed... yay
Good news... care to share the solution with us for people googling ?
Re: Set src of a childNode?
Posted: Tue May 31, 2011 10:37 pm
by unemployment
jacek wrote:unemployment wrote:fixed... yay
Good news... care to share the solution with us for people googling ?
this.parentNode.parentNode.parentNode.parentNode.previousSibling.childNodes.childNodes.src = "/assets/img/icons/process.png";
Needed to be...
this.parentNode.parentNode.parentNode.parentNode.previousSibling.firstChild.firstChild.src = "/assets/img/icons/process.png";
to fit my situation