I have a structure like below
<div data-example="1"></div>
<div data-example="2"></div>
<div data-example="1"></div>
<div data-example="3"></div>
<div data-example="2"></div>
<div data-example="2"></div>
<div data-example="4"></div>
To this structure additional divs can be added with different valued data-example 4-5-6-9 etc.
I want to get indexes of divs with same data-example attr and add it as html element. For example
<div data-example="1">Index is 0 for data 1</div>
<div data-example="2">Index is 0 for data 2</div>
<div data-example="1">Index is 1 for data 1</div>
<div data-example="3">Index is 0 for data 3</div>
<div data-example="2">Index is 1 for data 2</div>
<div data-example="2">Index is 2 for data 2</div>
<div data-example="4">Index is 0 for data 4</div>
For detail
Index is 0 for data 1 this is the first div whch have data-example with 1 value and this is the first div among the div which have data-example value 1 and its index is 0 the second div with data-example = 2 get the index 1.
How can I get the indexes dynamically with jquery.