I have a list of HTML article tags that are dynamically generated. Some of the article tags have a class named "featured". I want to insert some HTML right before the closing article tag where the class is named "featured" using plain javascript.
<article class="list-item featured">
....
</article>
<article class="list-item">
....
</article>
<article class="list-item featured">
....
</article>
<article class="list-item">
....
</article>
I tried using something like, but it did not work. I got an error: featuredItem.insertAdjacentHTML is not a function. What syntax should I be using to do this?
var featuredItem = document.getElementsByClassName("featured");
featuredItem.insertAdjacentHTML('beforeend','<div class="ribbon-featured"></div>');