If I have 5 divs like so :
<div id="container">
<div class="selected"></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
The div that is selected can be changed by clicking another. Now if I refresh the content of the container using ajax call I would like to keep the div selected. How do I acheive this?
I know I can get the selected div by using :
var selectedDiv = $('.selected');
But how do I use this to select it again?
Before you do the Ajax call, get the index of the selected
divand store it in a variable:Then, after you updated the content, use the index to selected the correct div: