Показать сообщение отдельно
  #12 (permalink)  
Старый 02.12.2016, 06:07
Новичок на форуме
Отправить личное сообщение для Warycooper Посмотреть профиль Найти все сообщения от Warycooper
 
Регистрация: 30.11.2016
Сообщений: 8

window.onload = function() {
		    document.getElementById('SuperButton').onclick = function()
		    {
		        if(document.getElementById('col').className != 'whitefon')
		        {
		            document.getElementById('col').className = 'whitefon';
		        }
		        else
		        {
		            document.getElementById('col').className = 'topic-content';
		        }
		    }
		}
		function getCookie(name) {
		  var matches = document.cookie.match(new RegExp(
		    "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
		  ));
		  return matches ? decodeURIComponent(matches[1]) : undefined;
		}
		$(function(){
			
			var yourcolor = getCookie('color');
			// alert(1);
			if(yourcolor){
				if(yourcolor=="button1"){

				} else if(yourcolor=="button2"){
					$('.button1').removeClass('active');
					$('.button2').addClass('active');
				}
			}
		$('.button1, .button2').click(function(){
		    $('.button1, .button2').toggleClass('active');
		    if($('.button1').hasClass('active')){
		    	var date = new Date(new Date().getTime() + 60 * 1000);
				document.cookie = "color=button1; path=/; expires=" + date.toUTCString();
		    } else if($('.button2').hasClass('active')){
		    	var date = new Date(new Date().getTime() + 60 * 1000);
				document.cookie = "color=button2; path=/; expires=" + date.toUTCString();
		    }
		  });
		});


Точнее записывает фон кнопки, а фон самого текста .whitefon нет.
Ответить с цитированием