Показать сообщение отдельно
  #5 (permalink)  
Старый 12.02.2016, 09:44
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

localStorage and checkbox
TTATPuOT,
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">

  </style>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

  <script>
   jQuery(document).ready(function($) {
	function readProperty(property, defValue){
		if(localStorage[property] == null){
			return defValue;
		}
		return JSON.parse(localStorage[property]);
	}
	$("#streams").prop('checked', readProperty("streams", true));

	$("#streams").change(function(){
		localStorage["streams"] = JSON.stringify($(this).prop('checked'));
	});
});

  </script>
</head>

<body>
 <input id="streams" name="" type="checkbox">
</body>

</html>
Ответить с цитированием