Hi Dhamodharan,
I think you want to expand the previous panel item when you select the last panel item.If that is the case use the below javascript
If you want a functionality other than this, please explain it here. I will help you to implement that.
Thanks,
A2H