# Retrieve the index of the current element

**URL:** https://discuss.prosemirror.net/t/retrieve-the-index-of-the-current-element/5927
**Category:** Uncategorized
**Created:** [October 19, 2023, 12:19pm UTC](https://discuss.prosemirror.net/t/retrieve-the-index-of-the-current-element/5927 "2023-10-19T12:19:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![keval6706](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/keval6706/32/3712_2.png) [@keval6706](https://discuss.prosemirror.net/u/keval6706)
#### Post date: [October 19, 2023, 12:19pm UTC](https://discuss.prosemirror.net/t/retrieve-the-index-of-the-current-element/5927/1 "2023-10-19T12:19:56Z")

</div>

I want to generate HTML in this manner.

However, the issue is: Is there a way to obtain the first and last elements from the content array? This would allow me to add and remove CSS classes accordingly.

Additionally, it would be beneficial if I could somehow retrieve the index of the current element as well as its siblings. Also length of content array.

 ![Screenshot 2023-10-19 at 5.44.22 PM](https://discuss.prosemirror.net/uploads/secondsite/original/2X/f/f66392ca2f0442d938e9f061d153e315142c9179.png)
