I have a few divs with the same class. The divs are generated dynamically, so I don’t always know the exact number of these divs.
I want to place another div after the last div.
<div class="someclassname">content here</div>
<div class="someclassname">content here</div>
<div class="someclassname">content here</div>
When I do this:
$('.someclassname').after('place another div here');
It places it after each one.
Is there a way to select the last div with .someclassname?
Use jQuery’s last selector like so:
If you want to select the last div with someclassname, and no other element type, then use this instead: