Skip to content

Instantly share code, notes, and snippets.

@eldoy
Created January 24, 2020 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eldoy/f3ee2bf5790e85bc8375ae58b6f9536f to your computer and use it in GitHub Desktop.
Save eldoy/f3ee2bf5790e85bc8375ae58b6f9536f to your computer and use it in GitHub Desktop.
function adaptFooter(x) {
var nav = document.querySelector('.navigation.mobile_block')
if (x.matches) {
var links = document.querySelectorAll('#footer li')
console.log(links)
var list = document.createElement('ul')
list.setAttribute('id', 'mobile-footer')
links.forEach(function(li) {
list.appendChild(li.cloneNode(true))
})
nav.appendChild(list)
} else {
var mobileFooter = document.querySelector('#mobile-footer')
if (mobileFooter) mobileFooter.remove()
}
}
var x = window.matchMedia("(max-width: 960px)")
adaptFooter(x)
x.addListener(adaptFooter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment