I have the following code:
In the function toolbar, I create a new element called newDiv. I want to insert this element inside the <span> tag using appendChild (or any method). How can I do this?
Perhaps there is a way of getting the parentNode of the <script> tag (the tag inside the span)? I do not want to name or id anything (so that I can have multiple instances of the code without changing anything).
Code:
<script>
function toolbar() {
newDiv = document.createElement("div");
???.appendChild(newDiv);
}
</script>
<body>
<span class="toolbar">
<script>toolbar( ... )</script>
</span>
</body>
In the function toolbar, I create a new element called newDiv. I want to insert this element inside the <span> tag using appendChild (or any method). How can I do this?
Perhaps there is a way of getting the parentNode of the <script> tag (the tag inside the span)? I do not want to name or id anything (so that I can have multiple instances of the code without changing anything).