jquery .before() if class isn't present
- by Afonso Gomes
Using pagination, I have a div structure like so in the first page:
<div class="ctema">...</div>
<hr />
<div class="ctema">...</div>
<hr />
<div class="ctema">...</div>
<hr />
But with a jquery script to fetch content via AJAX... the following pages have only:
<div class="ctema">...</div>
<div class="ctema">...</div>
<div class="ctema">...</div>
I tried this:
$('.ctematicas').before('<hr />');
But this doesn't checks if the HR tag is there or not and after 5 dynamic reloads In the first page I have 5 HR in a row ...
How can I check if the HR tag is present between classes CTEMA and add one if not present?