Reputation: 23475
I have the following javascript code, but when I try to use it on the 3rd line, I get [object HTMLHeadingElement]
in the HTML output. How do I take the whole HTML of x
and prepend it to y.innerHTML
?
x = document.getElementById("region-footer-first").getElementsByClassName("block-title")[0];
y = document.getElementById("region-footer-first").getElementsByClassName("jcarousel-clip")[0];
y.innerHTML = x + y.innerHTML;
Upvotes: 0
Views: 264
Reputation: 7416
If you want the entire contents of x
, including its tags, use .outerHTML
, like this
x = document.getElementById("region-footer-first").getElementsByClassName("block-title")[0];
y = document.getElementById("region-footer-first").getElementsByClassName("jcarousel-clip")[0];
y.innerHTML = x.outerHTML + y.innerHTML;
Upvotes: 5