const elements = document.querySelectorAll('li > ul');
const tag = 'span';
const text = 'hello, world!!';
elements.forEach(n => {
n.before(document.createElement(tag));
n.previousSibling.textContent = text;
});
for (const n of elements) {
const el = document.createElement(tag);
el.innerText = text;
n.parentNode.insertBefore(el, n);
}
for (let i = 0; i < elements.length; i++) {
elements[i].insertAdjacentHTML('beforebegin', `<${tag}>${text}</${tag}>`);
}
(function insert(i, n = elements.item(i)) {
if (n) {
const el = document.createElement(tag);
el.appendChild(new Text(text));
n.insertAdjacentElement('beforebegin', el);
insert(-~i);
}
})(0);
$('.list-item').filter((i, n) => $(n).data('pagereview') !== $(n).data('pageslug')).hide();
$('[data-pageslug]').each(function() {
const $this = $(this);
$this.toggle($this.attr('data-pagereview') === $this.attr('data-pageslug'));
});
document.querySelectorAll('.list-item').forEach(n => {
n.hidden = n.getAttribute('data-pagereview') !== n.getAttribute('data-pageslug');
});
for (const { style, dataset } of document.getElementsByClassName('list-item')) {
if (dataset.pagereview !== dataset.pageslug) {
style.display = 'none';
}
}
.hidden {
display: none;
}
const items = document.querySelectorAll('[data-pageslug]');
for (let i = 0; i < items.length; i++) {
const { classList: c, attributes: a } = items[i];
c.toggle('hidden', a['data-pagereview'].value !== a['data-pageslug'].value);
}
:options="{ scrollWheelZoom: false }"
@update:zoom="zoom = $event"
@wheel.native="onWheel"
methods: {
onWheel(e) {
if (e.deltaY < 0) {
this.zoom++;
e.preventDefault();
}
},
},
options: [
{
...
propToBeMultipliedByPrice: 'area',
},
{
...
propToBeMultipliedByPrice: 'perimeter',
},
],
{{ option.price * calc[option.propToBeMultipliedByPrice] }}
преобразовать
['a' => [11, 12], 'b' => [21, 22]]
в
[['a' => 11, 'b' => 12], ['a' =>21, 'b' => 22]]
12
из a
становится значением свойства b
, а 21
- наоборот? Опечатка? - наверное, в a
исходного массива лежат значения свойств a
результата, аналогично и с b
.array_map(fn($i) => array_combine(array_keys($arr), array_column($arr, $i)), array_keys(array_values($arr)[0]))
{{ dish[`title_${lang}`] }}
v-text="dish['title_' + lang]"
:text.prop="dish['title_'.concat(lang)]"
не корректно работает
data: () => ({
scroll: 0,
}),
computed: {
buttonClass() {
return что-то, зависящее от значения this.scroll;
},
},
created() {
const { body } = document;
const onScroll = () => this.scroll = body.scrollTop;
body.addEventListener('scroll', onScroll);
this.$on('hook:beforeDestroy', () => body.removeEventListener('scroll', onScroll));
},
<button :class="buttonClass"></button>
$('.price_min_max_btn').click(function() {
const min = +$('.price_min').val() || 0;
const max = +$('.price_max').val() || Infinity;
$('.item_block_filter')
.hide()
.filter(function() {
const price = +this.dataset.price;
return min <= price && price <= max;
})
.show();
});
<div v-for="(story, idx) in stories" :key="idx">
<div v-for="n in stories.hits" :key="n.objectID">
.then(this.dates.push(response['dates'] ) ),
.then(response => this.dates = response.data.dates)
// или
.then(response => this.dates.push(...response.data.dates))
Как в данном случае правильно сделать...
Структуру данных менять нельзя
computed: {
filteredDialogs() {
const { dialogs, search } = this;
return search
? dialogs.filter(n => n.fullname.includes(search))
: dialogs;
},
},
v-if="dialogs.length > 0" v-for="(dialog, index) in dialogs"
<ul class="chat--messages__wrapper" ref="messages">
this.$nextTick(() => {
const { messages } = this.$refs;
messages.scrollTop = messages.scrollHeight;
});
def countCarsByBrand(cars, brands):
return sum(len(v.keys()) for k, v in cars.items() if k in brands)
print(countCarsByBrand(cars, [ 'Audi', 'BMW' ]))