emcee22
emcee22

Reputation: 1889

Display paragraph value inside textarea

Hello i have the following code : http://jsfiddle.net/yw7Zk/

var makeAreaEditable = function(event){
    var btn = event.target,
        li  = btn.parentNode,
        p   = li.getElementsByClassName('paratext')[0];

    p.style.display="none";
    btn.innerText="Ok";
    btn.onclick = saveEdit;
    var textareaEdit = document.createElement('textarea');
    textareaEdit.className = 'testarea';
    li.appendChild(textareaEdit);
    textareaEdit.appendChild(p);
    textareaEdit.style.display="block";
};

The problem is that i want the paragraf display: none when i press the button edit but i want it displaied in the textarea.. so please help

Upvotes: 0

Views: 104

Answers (1)

Gareth Cornish
Gareth Cornish

Reputation: 4356

Try changing:

textareaEdit.appendChild(p);

into:

textareaEdit.value = p.innerHTML;

Upvotes: 1

Related Questions