function makeItem(title) {
return `<a class="dropdown-item"><i class="icon icon-line-circle"></i><span>${title}</span></a>`;
}
fetch('../russia.json')
.then(response => response.json())
.then(json => {
const itemsHtmlString = json.map(item => makeItem(item.city)).join()
$('.search__city .dropdown-menu').html(itemsHtmlString);
});
let dataList = {};
fetch('https://api.hh.ru/areas/113').then(response => {
return response.json();
}).then(
json => {
const cities = json.areas.reduce((array, area) => {
const citiesAtArea = area.areas.reduce((citiesArray, city) => {
return [...citiesArray, city.name]
}, [])
return [...array, ...citiesAtArea]
}, [])
console.log(cities)
}
);
querySelector('input[type="tel"]');
<label>
<input type="checkbox">
</label>
<label>
<input type="checkbox">
</label>
<label>
<input type="checkbox">
</label>
<button disabled>Кнопка</button>
const inputs = [...document.querySelectorAll('input')]
const button = document.querySelector('button')
const onInput = () => {
if(document.querySelector('label.checked')) {
button.disabled = false
} else {
button.disabled = true
}
}
inputs.forEach(input => input.addEventListener('input', function(event) {
if (event.target.checked) {
event.target.closest('label').classList.add('checked')
} else {
event.target.closest('label').classList.remove('checked')
}
onInput()
}))