Reputation: 1512
I've found some similar questions but never exactly this one:
I want to change the src of my img tag
<div id="probe1pic"><img height="193" width="150" src=""/></div>
and I want to do so with my jquery code from my variable x
x = {word: "David", pic: "<img id='pic' src='images/stimuli/david.gif'/>", type: "probe", cat: "perp"}
and if I isolate the pic element with x.pic
I get:
<img id='pic' src='images/stimuli/david.gif'/>
I thought about this to get the src element (unsuccessful):
x.pic.attr('src')
I probably need the id for of the img tag I want to get the attribute from which I do not know beforehand. I do not know the id nor the src beforehand, only my variable x with these elements, so I need to find a way to extract the src element from x (or the id at least).
Any ideas?
Upvotes: 0
Views: 274