JSFiddle - React, Tailwind, and code Playground

by wllai2001

HTML

<div class="noshowagain">
      <input type="checkbox" name="noread" id="noshowagain2">
        <label for="noshowagain2">請不要再次顯示</label>
</div>

<div id="msg">
null
</div>

<button id="switch">
紀錄顯示資料
</button>

JavaScript

$(function(){
 
   if (typeof (Storage) !== "undefined") {

   } else {
     alert("此瀏覽器不支援Web Storage");
   }
  
	
	 $("#msg").html(" 顯示紀錄:"+localStorage.nopop);      
   
   $("#noshowagain2").prop("checked",localStorage.nopop);
   
   $("#switch").on("click",function(){
   	
    	localStorage.nopop = $("#noshowagain2").prop("checked"); 
    	$("#msg").html(" 顯示紀錄:"+localStorage.nopop);
    	alert("已記錄資料:"+localStorage.nopop);
   });
});