Jump to content
  • Sign Up

Ekaterina

Neophyte
  • Posts

    1
  • Joined

  • Last visited

Information

  • Sex
    женский

Ekaterina's Achievements

Explorer

Explorer (1/14)

  • Week One Done Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. Всем привет! Помогите правильно поставить localStorage в скрипт. У меня почему-то не срабатывает, и при обновлении страницы теряется класс актив. Пробовала много разных вариаций, но всё равно не срабатывает, не могу понять, что не нравится. Сам скрипт: <input <?= $checked; ?> type="checkbox" id="compareid_<?= $arItem['ID']; ?>" data-id="<?= $arItem['ID']?>" onchange="compare_tov(<?= $arItem['ID']; ?>);"> <label for="compareid_<?= $arItem['ID']; ?>" style="display: block; width: 36px; height: 36px; position: absolute; top: 55px;"> <span class="comparTov_<?= $arItem['ID']; ?>" style="background:url(image1.png);"></span> </label> function compare_tov(id) { var chek = document.getElementById('compareid_'+id); if (chek.checked) { //Добавить var AddedGoodId = id; $.get("/local/ajax/list_compare.php", { action: "ADD_TO_COMPARE_LIST", id: AddedGoodId}, function(data) { $('#my_compare_list_count').html(data); var activeID = $('.comparTov_'+id).html('<img src="image2.png" />').addClass('active'); console.log(activeID); localStorage.getItem("active", activeID); } ); } else { //Удалить var AddedGoodId = id; $.get("/local/ajax/list_compare.php", { action: "DELETE_FROM_COMPARE_LIST", id: AddedGoodId}, function(data) { $('#my_compare_list_count').html(data); var activeID = $('.comparTov_'+id).html('<img src="image1.png" />').removeClass('active'); console.log(activeID); localStorage.removeItem("active", activeID); } ); } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy