Reputation: 39
Using an onclick function, I'm trying to take the content from a hidden div, and place it into a visible div. Instead of the content showing up, I get [object HTMLDivElement] instead. How do I fix that?
My code:
function infoclick1(){
var x = document.getElementById('HIDE1');
document.getElementById('moreinfo').innerHTML = x;
}
Upvotes: 1
Views: 1463
Reputation: 94499
function infoclick1(){
var x = document.getElementById('HIDE1').innerHTML;
document.getElementById('moreinfo').innerHTML = x;
}
Working Example: http://jsfiddle.net/WK8sW/
Upvotes: 2
Reputation: 15812
You want to set it to x's innerHTML, so
document.getElementById('moreinfo').innerHTML = x.innerHTML;
Upvotes: 1