Set src of a childNode?

JavaScript related questions should go here.
Post Reply
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Set src of a childNode?

Post 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";
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Set src of a childNode?

Post 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 ?
Image
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Set src of a childNode?

Post 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
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Set src of a childNode?

Post by unemployment »

fixed... yay
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Set src of a childNode?

Post by jacek »

unemployment wrote:fixed... yay
Good news... care to share the solution with us for people googling ?
Image
unemployment
Posts: 165
Joined: Fri May 06, 2011 5:02 pm

Re: Set src of a childNode?

Post 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
Post Reply