everybody. I wanna make a for
loop outputting my h3
elements. I could do it for one of them but to have them all, it doesn't output the content.
And the a
in the loop is for making inner links of my h3
in a long page.
function showH() {
var x = document.getElementsByTagName("H3");
let str = '<a href="">';
for (var i =0; i < x.length; i++) {
str += x[i] + "</a>";
}
document.getElementById("get").innerHTML = str;
}
<p id="get"></p>
<button onclick="showH()">click</button>
this code outputs:
[object HTMLHeadingElement][object HTMLHeadingElement][object HTMLHeadingElement][object HTMLHeadingElement]