0

День добрый. Есть js скрипт:

$(document).ready(function() {
if($(window).width() > 700) {
    $('#to-catalog').click(function(){
        var toLoad = $(this).attr('href')+' #ajax-right-col';
        $('#ajax-right-col').hide('fast',loadContent);
        function loadContent() {
            $('#ajax-right-col').load(toLoad,'',showNewContent())
        }
        function showNewContent() {
            $('#ajax-right-col').show('normal');
        }
        return false;
    });
}

Мне необходимо настроить работу этого кода так, чтобы он срабатывал на разрешении только меньше 700 пикселей. В противном случае - на разрешениях выше - скрипт срабатывать не должен. Подскажите, как можно это сделать?

1 ответ 1

0

Вот так?

$(document).ready(function() {
  $('#to-catalog').click(function(){
    if($(window).width() < 700) {
      var toLoad = $(this).attr('href')+' #ajax-right-col';
      $('#ajax-right-col').hide('fast',loadContent);
      function loadContent() {
        $('#ajax-right-col').load(toLoad,'',showNewContent())
      }
      function showNewContent() {
        $('#ajax-right-col').show('normal');
      }
      return false;
    }
  });
});

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.