106
rated 0 times
[
111]
[
5]
/ answers: 1 / hits: 35831
/ 10 Years ago, tue, november 25, 2014, 12:00:00
I had this problem when I get the value from a div:
function sync(){
var n1 = document.getElementById('editor').value;
alert(n1);
var n2 = document.getElementById('news');
n2.value = n1;
}
div with id editor
looks like this:
<div class='message' id='editor' contenteditable=true onkeyUp='sync()' style=color: black></div>
When I put something in that div it will alert me undefined and that will also come in the textarea i paste it in too. So the problem is obviously by this:
var n1 = document.getElementById('editor').value;
What am I doing wrong?
More From » html