inserting before after a tag using javascript code example
Example: javascript insert html before element
// add without creating a new element
document.getElementById('my_id')
.insertAdjacentHTML('beforebegin', 'your_html_code');
// add without creating a new element
document.getElementById('my_id')
.insertAdjacentHTML('beforebegin', 'your_html_code');