Skip to content Skip to sidebar Skip to footer

How To Insert An Element At The Current Position In Html Using Prototype

How do you insert an HTML element dynamically (using prototype) at the current position if you don't know the id of the parent element? All examples I've seen assumes the element h

Solution 1:

The only way I can think of is finding the <script> element and insert the element before/after the script. The thing is, all DOM methods need a DOM node to operate on. Executing scripts that modify the DOM before the document has loaded isn't a good and safe idea.

Similar questions linked below.

  1. JavaScript: get the current executing <script> node?
  2. How may I reference the script tag that loaded the currently-executing script?

Post a Comment for "How To Insert An Element At The Current Position In Html Using Prototype"