<div
v-for="item in items"
class="col-md-3 services-item"
:class="{ hoverClass: item.hover }"
>
<img :src="item.scr" alt="">
<h3 class="my_services_title">Тест</h3>
<button
class="btn-price"
@mouseenter="item.hover = true"
@mouseleave="item.hover = false"
>Нажать</button>
</div>
data: {
items: [
{
src: 'img/laptop.png',
hover: false,
},
{
src: 'img/laptop.png',
hover: false,
},
],
},
$('li, div, p', '#wrapper').attr('custom-attr', i => `test${i + 1}`);
document
.querySelector('#wrapper')
.querySelectorAll('li, div, p')
.forEach((n, i) => n.setAttribute('custom-attr', 'test' + -~i));
success(response) {
$('#api-wb').html(JSON.parse(response).loads.map(n => `
<div class="item">
<div><b>${n.title}</b></div>
<div><a href="${n.comments_url}">comments (${n.comments_num})</a></div>
<div><img src="${n.files[0].small}"></div>
</div>
`).join(''));
}
const arr3 = arr1.map(n => (arr2.find(m => m.date === n) || { count: null }).count);
const obj = arr2.reduce((acc, n) => (acc[n.date] = n.count, acc), {});
const arr3 = arr1.map(n => obj[n] || null);
const arr3 = arr1.map(function(n) {
return this.get(n) || null;
}, new Map(arr2.map(n => [ n.date, n.count ])));
const statusArray = object.map(item => {
const opts = {
maxResults: 5,
key: users[2].token,
};
return new Promise((resolve, reject) => {
search(item.title, opts, (err, videos) => {
if (err) {
throw err;
}
item.youtubeId.new = videos[0].id;
item.videos = videos;
resolve(ArticleController.addArticle(item));
});
});
});
// достаёте компонент из пропсов, обратите внимание, что
// имя переменной должно начинаться с большой буквы
const Component = this.props.component;
// ну и рендерите его
<Component />
const parent = document.querySelector('ul');
const className = 'elem';
const count = 2;
for (let i = parent.children.length, j = count; i-- && j--;) {
parent.children[i].classList.remove(className);
}
// или
Array.prototype.forEach.call(parent.children, (n, i, a) => {
n.classList.toggle(className, i + count < a.length);
});
// или
parent.querySelectorAll(`.${className}:nth-last-child(-n + ${count})`).forEach(n => {
n.classList.value = n.classList.value.replace(RegExp(`(^| )${className}( |$)`), ' ').trim();
});
// или
for (
let i = 0, el = parent.lastElementChild;
i < count && el;
i++, el = el.previousElementSibling
) {
el.className = el.className.split(' ').filter(n => n !== className).join(' ');
}
$('.one .qwer').css('font-size', i => `${12 + i * 4}px`);
document.querySelectorAll('.one .qwer').forEach((n, i) => {
n.style.fontSize = (-~-~-~i << 2) + 'px';
});
const items = document.querySelectorAll('.one .qwer');
for (let i = 0, j = 12; i < items.length; i++, j += 4) {
items[i].style.setProperty('font-size', ''.concat(j, 'px'));
}
const getTableData = ({ rows: [ head, ...rows ] }) =>
rows.map(function({ cells: c }) {
return this.reduce((obj, key, i) => (
obj[key] = c[i].innerText,
obj
), {});
}, Array.from(head.cells, n => n.innerText));
const tableData = getTableData(document.querySelector('table'));
const selector = '.active';
.const $result = $(selector).nextAll().addBack();
// или
const result = document.querySelectorAll(`${selector}, ${selector} ~ *`);
// или
const result = [];
for (
let el = document.querySelector(selector);
el;
el = el.nextElementSibling
) {
result.push(el);
}
// или
const el = document.querySelector(selector);
const siblings = el ? [...el.parentNode.children] : [];
const result = siblings.slice(siblings.indexOf(el));