I am a newbie. Here is my code:
It should be:
document.getElementById("comment_content").value =
document.getElementById("username").innerHTML
Without the .innerHTML
, it will try to copy in the actual element, not its content.
You can use textContent,innertext,innerHTML.But two of them are browser specific and innerHTML can work on three major browser.
Also you can parse the dom by parent children combination and will get required value.
function replyOne () {
document.getElementById("comment_content").value=document.getElementById("username").innerHTML;
//OR
document.getElementById("comment_content").value=document.getElementById("username").textContent;
}