我有一個頁面上的按鈕另一個頁面上的另一個按鈕。此第二個按鈕的文本中包含「已選擇0個項目」。當第一個按鈕被點擊時,我想增加第二個按鈕中的數字。如何在jQuery中使用會話變量?
看到它正在通過不同的頁面傳輸數據我沒有設法做到這一點的標準方式。
請不要暗示PHP,我無法使用它。
var yetVisited = localStorage[0];
if ($('.#CallToActionCustomise').click()){
\t localStorage++;
}
$('.#CallToActionCustomise').click(function(){
\t $(".Main_MenuButtonReview").append(localStorage);
});
<button class="Main_MenuButtonReview">0 items selected <i class="fa fa-caret-down"></i></button>
localStorage不是數組。這是一個對象。你不能增加一個對象?在localStorage中定義一個變量,它將工作:'localStorage.myCounter'例如 –