Link to home
Start Free TrialLog in
Avatar of Tammu
Tammu

asked on

How to pass to assign an variable value to an element

I have an element and I am trying to pass a variable value of another element. here is my code

var links = document.createElement ('li');
 var img = document.createElement( 'img');
img.src = option.image;  // this gives the path of the image
img.alt = option.prompt;

links.appendChild( img );

var s1 = document.createElement('span');

Open in new window


In the above code I want to display option.prompt  ( the value) in s1. So using createTextNode won't help as it will only display option.prompt but not its value. this is where I am stuck.

any advice or examples are appreciated
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tammu
Tammu

ASKER

Thanks