$("#divid1").click(function(){
$("#divid1").hide(); //want this to keep hidden after refresh
$("#hideid1").hide(); //want this to keep hidden after refresh
$("#id1").show(); //want this to keep showing after refresh
});
.hide{
display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="/img/done.png" id="divid1" alt="divid1"/>
<img src="/img/schedule.png" height="12" width="12" id="hideid1" alt="hideid1" />
<div id="id1" class="hide"><img src="/img/done.png" height="12" width="12" alt="id1" /></div>
我試圖頁面加載時的onclick後顯示圖像();顯示新圖像並隱藏舊圖像。 但在頁面刷新時重置。
請給我一個方法來解決它。
工作代碼與我的ids將被讚賞!
'localStorage'可以提供一個解決方案 – depperm
我不知道如何使用它@depperm – monemacu
http://stackoverflow.com/questions/16206322/how-to-get-js -variable-to-retain-value-after-page-refresh – epascarello