JavaScript
21
Вклад в тег
var a = [{
"id": "1",
"title": "Дом1"
}, {
"id": "2",
"title": "Зал2"
}, {
"id": "3",
"title": "Дом3"
}, {
"id": "4",
"title": "Зал4"
}];
for (let i of a) {
i.active = false;
}
console.log(a);
window.onscroll = function() {
let scrolled = window.pageYOffset || document.documentElement.scrollTop;
(scrolled >= 100) ? document.querySelector('.header').classList.add('head-scroll') :
document.querySelector('.header').classList.remove('head-scroll');
}
var cities = {
bra: ["Сан-Паулу", "Рио-де-Жанейро"],
rus: ["Москва", "Санкт-Петербург"],
ind: ["Мумбаи", "Дели"],
chn: ["Шанхай", "Пекин"],
zaf: ["Йоханнесбург", "Кейптаун"]
};
var country = document.getElementById("country");
var city = document.querySelector("#city");
window.onload = selectCountry(city, cities);
country.onchange = function() {
selectCountry(city, cities);
}
function selectCountry(city, ev) {
city.innerHTML = "";
var c = country.value || "bra",
o;
for (let i = 0; i < ev[c].length; i++) {
o = new Option(ev[c][i], ev[c][i], false, false);
city.add(o);
};
}