Solved

How to pass to assign an variable value to an element

Posted on 2013-01-07
2
147 Views
Last Modified: 2013-01-22
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
0
Comment
Question by:niceoneishere
2 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 38752844
If I understand this you want the string in option.prompt so:

s1.innerHTML=option.prompt;

if you want the literal option.prompt then

s1.innerHTML='option.prompt';

Cd&
0
 
LVL 1

Author Closing Comment

by:niceoneishere
ID: 38808480
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Read about why website design really matters in today's demanding market.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now