2016-09-28 2 views
0
$.jAlert({ 
'content' : 'Now I will show this alert and increment sessionStorage my_variable by 1.', 
'onClose' : function(alert) { 
sessionStorage.setItem("my_variable", "this_is_the_value_i_need_to_increment"); 
} 
}); 

이 경고가 도시되어 처음 나타낸다 "this_is_the_value_i_need_to_increment"경고를 나타내는 제 2 타임 1이어야 "this_is_the_value_i_need_to_increment"등등 2 및이어야한다.마다 경고가 증가 sessionStorage 값

이것이 가능합니까? 감사합니다.

답변

1

단지 정수 1을 증가시키고 다음과 같이 다시 항목을 설정하는 구문 분석 :

sessionStorage.setItem("my_variable",0); 
:
$.jAlert({ 
    'content' : 'Now I will show this alert and increment sessionStorage my_variable by 1.', 
    'onClose' : function (alert) { 
     sessionStorage.setItem("my_variable", 1 + parseInt(sessionStorage.getItem("my_variable"))) 
    } 
}); 

물론, my_variable 같은 경고하기 전에 초기화되어야한다