@enerjze

Как поменять значение по умолчанию?

На сайте есть переключатель отображения новостей, он добавляет или удаляет класс colum right. Я хочу, чтобы по умолчанию на всех устройствах этот класс был отключен
var hide_side_trig = 0;
    var hide_side =  $.cookie("hide_side");
    if (hide_side == "1") {
        hide_side_trig = 1;
        $("#colum_right").hide();
        $('.hide_side').addClass("active");
        $(".users_news, .boxes_news").addClass("long");
        $("#colum_left").animate({"width":"1230px"}, function(){
         $(".short_news").each(function(){
             $(this).css({"width":"292px"});
          });
           $('.mas_news').masonry({
              itemSelector: '.short_news',
              singleMode: false,
              isResizable: true,
              "gutter": 20,
              isAnimated: true,
                  animationOptions: { 
                  queue: false, 
                  duration: 500 
              }
           });
           $.cookie("hide_side", "1", {
             expires : 360,           //expires in 10 days
             path    : '/',          //The value of the path attribute of the cookie 
             domian  : 'mexalim.com.ua'
          });
        });
    }       


    $('.hide_side').click(function(){
      $("#colum_right").fadeToggle();
      $(this).toggleClass("active");
      if (hide_side_trig == 0) {
        hide_side_trig = 1;
        $(".users_news, .boxes_news").addClass("long");
        $("#colum_left").animate({"width":"1230px"}, function(){
         $(".short_news").each(function(){
             $(this).css({"width":"292px"});
          });
           $('.mas_news').masonry({
              itemSelector: '.short_news',
              singleMode: false,
              isResizable: true,
              "gutter": 20,
              isAnimated: true,
                  animationOptions: { 
                  queue: false, 
                  duration: 500 
              }
           });
           $.cookie("hide_side", "1", {
             expires : 360,           //expires in 10 days
             path    : '/',          //The value of the path attribute of the cookie 
             domian  : 'mexalim.com.ua'
          });
           $('.boxes_slider').bxSlider({
            slideSelector:'.boxes_slider_item',
            pagerCustom:'#bsi_nav_liks',
            controls:false
          }); 
        });
      } else {
        hide_side_trig = 0;
        $(".users_news, .boxes_news").removeClass("long");
        $("#colum_left").animate({"width":"910px"}, function(){
         $(".short_news").each(function(){
             $(this).css({"width":"289px"});
          });

          $('.mas_news').masonry({
            itemSelector: '.short_news',
            singleMode: false,
            isResizable: true,
            "gutter": 20,
            isAnimated: true,
                animationOptions: { 
                queue: false, 
                duration: 500 
             }
          });
          $.cookie("hide_side", "2", {
             expires : 360,           //expires in 10 days
             path    : '/',          //The value of the path attribute of the cookie 
             domian  : 'mexalim.com.ua'
          });
          $('.boxes_slider').bxSlider({
            slideSelector:'.boxes_slider_item',
            pagerCustom:'#bsi_nav_liks',
            controls:false
          }); 
        });
      }
      
    });

Пробовал менять var hide_side = $.cookie("hide_side"); на var hide_side = 1; на компьютере норм, на телефоне нет.
  • Вопрос задан
  • 98 просмотров
Пригласить эксперта
Ответы на вопрос 1
Krasnodar_etc
@Krasnodar_etc
fundraiseup
Ну, уберите вообще условие if (hide_side == "1") {

и просто всегда выполняйте то, что внутри него
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы