partyzanx
@partyzanx

Как в скрипте убрать выделение?

Есть скрипт плавного скрула к ссылке. Но когда он переходит по якорю, то этот самый якорь выделяется голубыми границами. Что изменить в скрипте, чтобы не было этого выделения? Либо есть какие-то подобные скрипты плавного скрулла, основанные на тех же принципах, что этот ява скрипт?

ССЫЛКА НА СКРИПТ

5a2b7184ea25c745751052.png5a2b718924cea877627499.png
// Select all links with hashes
$('a[href*="#"]')
  // Remove links that don't actually link to anything
  .not('[href="#"]')
  .not('[href="#0"]')
  .click(function(event) {
    // On-page links
    if (
      location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 
      && 
      location.hostname == this.hostname
    ) {
      // Figure out element to scroll to
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
      // Does a scroll target exist?
      if (target.length) {
        // Only prevent default if animation is actually gonna happen
        event.preventDefault();
        $('html, body').animate({
          scrollTop: target.offset().top
        }, 1000, function() {
          // Callback after animation
          // Must change focus!
          var $target = $(target);
          $target.focus();
          if ($target.is(":focus")) { // Checking if the target was focused
            return false;
          } else {
            $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
            $target.focus(); // Set focus again
          };
        });
      }
    }
  });
  • Вопрос задан
  • 188 просмотров
Решения вопроса 3
@AnneSmith
самая ленивая
удалить
$target.focus();
Ответ написан
edli007
@edli007
full stack, team lead
a:focus {
    outline: none;
}
Ответ написан
Exploding
@Exploding
wtf?
Хз, я обычно в начальном ресете просто вот такие буквы пишу:
*{outline:none;}
И меня перестали беспокоить ночные кошмары.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

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

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