<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<style>
.active{
background-color: red;
}
</style>
</head>
<body>
<div class="fn_switch">1</div><div></div>
<div class="fn_switch">2</div><div></div>
<div class="fn_switch">3</div><div></div>
<div class="fn_switch">4</div><div></div>
<div class="fn_switch">5</div><div></div>
<div class="fn_switch">6</div><div></div>
<div class="fn_switch">7</div><div></div>
<script>
$(function(){
$('.fn_switch').click(function(e){
e.preventDefault();
$(this).next().slideToggle(300);
if ($(this).hasClass('active')) {
$(this).removeClass('active');
}
else {
$(this).addClass('active');
}
var arr = $.map($('.fn_switch'), function(el, i){
if($(el).hasClass('active')) return i;
});
localStorage.setItem('ind', JSON.stringify(arr));
});
var arr = JSON.parse(localStorage.getItem('ind'));
if(arr){
$('.fn_switch').filter(function(i){
return arr.includes(i);
}).addClass('active').next().show();
}
});
</script>
</body>
</html>
как вариант индексы запомнить