[...document.querySelectorAll('.itemAnswer')].map(answer => {
let blockQ = answer.querySelector('.item'),
closeBlock = answer.querySelector('.closed');
blockQ.addEventListener('click', () => answer.classList.add('itemAnswerOpen'));
closeBlock.addEventListener('click', () => answer.classList.remove('itemAnswerOpen'));
});
let goods = [
{ name: 'Береза', price: 150, img: 'img/Береза.jpg' },
{ name: 'Ель', price: 200, img: 'img/Ель.JPG' },
];
goods.map(good => {
let wrapper = document.createElement('div'),
name = document.createElement('div'),
price = document.createElement('div'),
image = document.createElement('img');
name.innerHTML = good.name;
price.innerHTML = good.price;
image.src = good.image;
image.style.width = '100px';
image.style.height = '100px';
wrapper.appendChild(name);
wrapper.appendChild(price);
wrapper.appendChild(image);
document.body.appendChild(wrapper)
});
$('.a').on('click', function() {
$('.fas', this).toggleClass('active');
});
fetch('https://woobl.ru/php/api/test/1.php?name=1')
.then(response => response.json())
.then(data => data.loads.map(load => console.log(load)));
$.ajax({
url: 'https://woobl.ru/php/api/test/1.php?name=1',
success: function(response) {
var data = JSON.parse(response);
data.loads.map(function (item) {
console.log(item)
})
}
});
JSON.parse()
const transplants = [0, 1, 2]; // пересадки
const prices = [10000, 15000]; // диапазон цен
// Фильтруем
const flights = tickets.filter(ticket => {
const ticketTransplant = transplants.includes(ticket.stops); // проверяем пересадки
const ticketPrice = ticket.price >= prices[0] && ticket.price <= prices[1]; // проверяем цену
return ticketTransplant && ticketPrice;
});
/**
* Enum for tri-state values.
* @readonly
* @enum {number}
*/
var triState = {
/** The true value */
TRUE: 1,
FALSE: -1,
/** @type {boolean} */
MAYBE: true
};