View Full Version : problem with text nodes and paragraphs

03-26-2012, 11:28 AM
I'm a beginner in Javascript and I'm trying to figure out how to add a text node in one function and then using it in another. What I want to do is explained in the comments in the code.
Grateful for any help I can get!

And I've tried to search for this in the forum but haven't found any info.

var txtnod;

* c might contain a value from clicking a button on the screen
* c - if it doesnt contains anything go to addParagraph

function addLetter(c){
if (txtnod)

* Here I want to add (c) to the end of the textnod created in the
* function addParagraph


* Clicking on ENTER (on screen) or if variable txtnod is empty calls this function

function addParagraph() {

/* This function should create a P element with a text node
* and also adding the paragraph to the div id "output"

var newParagraph=document.createElement('p');