I have an requirement to get the third occurence of a class name
The class name is coral-buttongroup.rte-toolbar
. How can i get the third occurence of this class and then append something to this.
I have tried with
$('.coral-buttongroup.rte-toolbar').eq(2).append('<button class="desc-count"></button>');
But this isn't working.
Your code works
$(function() {
$('.coral-buttongroup.rte-toolbar').eq(2)
.append('<button class="desc-count">Click</button>');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="coral-buttongroup rte-toolbar">1</div>
<div class="coral-buttongroup rte-toolbar">2</div>
<div class="coral-buttongroup rte-toolbar">3</div>
<div class="coral-buttongroup rte-toolbar">4</div>