Created
May 2, 2018 14:26
-
-
Save vladanyes/ed35470a139d3bec2e586ea9c8f3f941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function addNewElem() { | |
// //adding banner element to the top of the page | |
// var div = document.createElement('div'); | |
// div.className = "sale-banner--mobile"; | |
// div.innerHTML = "BOOK NOW TO GET YOUR FIRST PICK UP FREE"; | |
// var createdDiv = document.querySelectorAll('.sale-banner--mobile'); | |
// | |
// if (window.matchMedia("(max-width: 685px)").matches && createdDiv.length <= 0) { | |
// document.body.insertBefore(div, document.body.firstChild); | |
// } | |
// if (window.matchMedia("(min-width: 686px)").matches) { | |
// for (var i = 0; i < createdDiv.length; ++i) { | |
// createdDiv[i].remove(); | |
// } | |
// } | |
// } | |
function addNewElem() { | |
//adding banner element to the top of the page | |
var createdDiv = document.querySelectorAll('.sale-banner--mobile'); | |
var div = document.createElement('div'); | |
div.className = "sale-banner--mobile"; | |
div.innerHTML = "BOOK NOW TO GET YOUR FIRST PICK UP FREE"; | |
if (window.matchMedia("(max-width: 685px)").matches) { | |
document.body.insertBefore(div, document.body.firstChild); | |
} | |
for (var i = 0; i < createdDiv.length; ++i) { | |
createdDiv[i].remove(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment