简体   繁体   中英

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

Try changing:

textareaEdit.appendChild(p);

into:

textareaEdit.value = p.innerHTML;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM