JavaScript
6
Вклад в тег
window.addEventListener('load', () => {
const toggle = document.querySelector('#js-toggle')
const body = document.querySelector('#js-body')
const nav = document.querySelector('#js-nav')
const menuBg = document.querySelector('#js-menu-bg')
const toggleNav = document.querySelector('#js-toggle-nav')
const openCloseMenu = () => {
toggle.classList.toggle('toggle--active')
body.classList.toggle('body--overflow')
nav.classList.toggle('header__nav--active')
menuBg.classList.toggle('menu-bg--active')
}
for (const clickEl of [toggle, toggleNav, menuBg]) {
clickEl.addEventListener('click', openCloseMenu)
}
})
Нормальный ли прием с arrayElemOnClick ?
$(document).ready(function() {
const url = document.location.href;
var link = $('.tg-button > a');
var href = 'https://ya.ru?';
if(url.match(/utm_source=/)){
href += '&utm_source=' + window.location.search.split('utm_source=')[1].split('&')[0];
}
if(url.match(/utm_medium=/)){
href += '&utm_medium=' + window.location.search.split('utm_medium=')[1].split('&')[0];
}
if(url.match(/utm_campaign=/)){
href += '&utm_campaign=' + window.location.search.split('utm_campaign=')[1].split('&')[0];
}
link.attr('href', href);
});