My goal is to determine the number of div elements on a page and then insert my ad codes after the second div.
It seems like using jQuery's .after method is not effective in this scenario.
<script>
$(function() {
var count = $('.panel-footer.clearfix').length;
if (count >= 3) {
$('.panel-footer.clearfix').eq(1).after(`<script async
src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"> .
</script>
<ins class="adsbygoogle"
style="display:inline-block;width:320px;height:100px"
data-ad-client="ca-pub-3767785488130692"
data-ad-slot="3213073317"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>`);
}
});