работает, но не всегда корректно <...> точно есть ошибки
SELECT t1.time, t1.value AS temp_val, t2.value AS hum_val
FROM topics t1
JOIN topics t2 ON t2.time = t1.time
WHERE
t1.topic = 'tempinroom' AND
t2.topic = 'huminroom'
при вводе каждого символа с поля слетает фокус
this.form.company_ids.push({
key: this.form.company_ids.length,
});
this.form.company_ids.push({
key: ++this.currKey,
});
this.form.company_ids.push({
key: Math.max(0, ...this.form.company_ids.map(n => n.key)) + 1,
});
const selector = 'div p';
const removeFromStart = 5;
const removeFromEnd = 3;
document.querySelectorAll(selector).forEach((n, i, a) => {
if (i < removeFromStart || i > a.length - removeFromEnd - 1) {
n.remove();
}
});
document.querySelectorAll([
`${selector}:nth-child(-n+${removeFromStart})`,
`${selector}:nth-last-child(-n+${removeFromEnd})`,
]).forEach(n => n.outerHTML = '');
<div class="counter">
<button class="minus">-</button>
<input type="number" min="2" max="17" value="5">
<button class="plus">+</button>
</div>
const updateInput = change => e =>
$('input', e.delegateTarget).val(function(i, v) {
const min = this.min || -Infinity;
const max = this.max || Infinity;
return Math.max(min, Math.min(max, (v | 0) + change));
});
$('.counter')
.on('click', '.minus', updateInput(-1))
.on('click', '.plus', updateInput(1))
.on('input', updateInput(0));
const updateInput = change => e => {
const input = e.target.closest('.counter').querySelector('input');
const min = input.min || -Infinity;
const max = input.max || Infinity;
input.value = Math.min(max, Math.max(min, (input.value | 0) + change));
};
document.querySelectorAll('.counter').forEach(function(n) {
n.querySelector('.minus').addEventListener('click', this[0]);
n.querySelector('input').addEventListener('input', this[1]);
n.querySelector('.plus').addEventListener('click', this[2]);
}, [ -1, 0, 1 ].map(updateInput));
document.addEventListener('click', ({ target: t }) => {
const change = -t.matches('.plus') || +t.matches('.minus');
if (change) {
const input = t.closest('.counter').querySelector('input');
input.value -= change;
input.dispatchEvent(new Event('input', { bubbles: true }));
}
});
document.addEventListener('input', ({ target: t }) => {
if (t.closest('.counter')) {
t.value = Math.min(t.max || Infinity, Math.max(t.min || -Infinity, t.value | 0));
}
});
<button class="minus" data-change="-1">-</button>
<button class="plus" data-change="+1">+</button>
document.addEventListener('input', updateInput);
document.addEventListener('click', updateInput);
function updateInput({ target: t }) {
const counter = t.closest('.counter');
if (counter) {
const input = counter.querySelector('input');
const min = input.min || -Infinity;
const max = input.max || Infinity;
input.value = Math.min(max, Math.max(min, (input.value | 0) + (t.dataset.change | 0)));
}
}
position = anchor.position().top;
position = anchor.position().top + $('#container').scrollTop();
:visible
. Вот с его помощью и отбирайте следующее изображение, например так.:visible
лучше использовать его (в примере по ссылке выше можно просто заменить одно на другое). const buttonSelector = 'button';
const getButtons = () => document.querySelectorAll(buttonSelector);
document.addEventListener('click', e => {
if (e.target.matches(buttonSelector)) {
const buttons = getButtons();
const texts = Array.from(buttons, n => n.textContent);
for (const [ i, n ] of buttons.entries()) {
n.textContent = texts[-~i % texts.length];
}
}
});
const buttons = getButtons();
const onClick = () =>
buttons.forEach(function(n, i) {
n.innerText = ++i === buttons.length ? this : buttons.item(i).innerText;
}, buttons.item(0).innerText);
buttons.forEach(n => n.addEventListener('click', onClick));
const div = document.querySelector('.line');
div.removeChild(div.childNodes[2]);
// или
document.querySelector('.line input').nextSibling.remove();
// или
document.querySelector('.line').lastChild.remove();
methods: {
group(item) {
return item && Object.entries(this.groups).find(([ k, v ]) => v.includes(item.group))[0];
},
computed: {
selectedGroup() {
return this.group([].concat(...this.data.map(n => n.items)).find(n => n.checked));
},
<ul v-for="{ items } in data">
<li v-for="item in items">
<label>
<input
type="checkbox"
v-model="item.checked"
:disabled="selectedGroup && selectedGroup !== group(item)"
>
{{ item.name }} ({{ group(item) }})
</label>
</li>
</ul>
SELECT table_name
FROM information_schema.columns
WHERE column_name = 'type_vendor'
const $headers = $('.bf-attr-group-header');
$headers.each(i => $headers
.eq(i)
.nextUntil($headers.get(i + 1))
.wrapAll('<div class="wrapper">')
);
document.querySelectorAll('.bf-attr-group-header').forEach((n, i, a) => {
const wrapper = document.createElement('div');
const elems = [];
for (let el = n; (el = el.nextElementSibling) && el !== a[i + 1]; elems.push(el)) ;
wrapper.append(...elems);
wrapper.classList.add('wrapper');
n.after(wrapper);
});
document.querySelectorAll('button').forEach(n => n.addEventListener('click', onClick));
function onClick() {
const count = (+this.dataset.clickCount || 0) + 1;
this.innerText = `clicked: ${count}`;
this.dataset.clickCount = count;
}
$('span').text((i, text) => text[0] === '-' ? text : `+${text}`);
document.querySelectorAll('span').forEach(n => {
n.innerText = n.innerText.replace(/^(?!-)/, '+');
});
for (const n of document.getElementsByTagName('span')) {
n.textContent = '+'.slice(n.textContent[0] === '-') + n.textContent;
}
function getUrls($parts, $acc = '') {
$urls = [];
if (count($parts)) {
$part = array_shift($parts);
if (!is_array($part)) {
$part = [ $part ];
}
foreach ($part as $p) {
array_push($urls, ...getUrls($parts, ($acc ? $acc.'/' : '').$p));
}
} else {
$urls[] = $acc;
}
return $urls;
}
$urls = getUrls($urlFragments);
data: () => ({
mainCategories: [
{ merchantId: '1', checked: true },
{ merchantId: '2', checked: true },
...
],
}),
computed: {
checkedCategories() {
return this.mainCategories.filter(n => n.checked).map(n => n.merchantId);
},
},
<li v-for="n in mainCategories">
<label>
<input type="checkbox" v-model="n.checked">
{{ n.merchantId }}
</label>
</li>
created() {
this.checkedCategories = this.mainCategories.map(n => n.merchantId);
},