$('form').on('change', 'select', function() {
$(this).parent().next().find('input').prop('disabled', this.value === 'No');
});document.querySelector('form').addEventListener('change', ({ target: t }) => {
if (t.tagName === 'SELECT') {
const { value } = t;
(t = t.parentNode.nextElementSibling) &&
(t = t.querySelector('input')) &&
(t.disabled = value === 'No');
}
});
function replaceDigits(str, matches) {
let count = 0;
return str.replace(/\d/g, d => matches.includes(++count) ? '*' : d);
}
replaceDigits('+7 (000) 000-00-00', [ 2, 3, 4 ]); // "+7 (***) 000-00-00"
replaceDigits('+7 (000) 000-00-00', [ 2, 3, 4, 5, 6, 7 ]); // "+7 (***) ***-00-00"
replaceDigits('+7 (000) 000-00-00', [ 10, 11 ]); // "+7 (000) 000-00-**"
{ required: true } - что вы хотели этим сказать? Непонятно. Вот вам пример валидации вашей формы, а вот ссылка на документацию - тоже пригодится.
str.split('/').pop()
//или
str.slice(str.lastIndexOf('/') + 1)
// или
[...str].reduce((acc, n) => n === '/' ? '' : acc + n, '')str.match(/[^\/]*$/)[0]
// или
str.replace(/.*\//, '')
max(array_map(function($n) {
return $n['ask']['c'];
}, $obj['candles']))max(array_column(array_column($obj['candles'], 'ask'), 'c'))
:value="name".v-for="(name, i) in names", v-model="checkboxValue[i]".
NOT IN я так понял https://w3resource.com/mysql/comparision-functions... работает начиная с 5.6
arr.map((n, i) => n ? i : null).filter(n => n !== null)
// или
arr.map((n, i) => n ? i : NaN).filter(n => n === n)
// или
arr.map((n, i) => !!n && i).filter(Number.isInteger)
// или
arr.map((n, i) => !n || i).filter(n => n !== !0)arr.reduce((acc, n, i) => n ? [ ...acc, i ] : acc, [])
// или
arr.reduce((acc, n, i) => (n && acc.push(i), acc), [])for (let i = arr.length; i--;) {
if (arr[i]) {
arr[i] = i;
} else {
for (let j = i; ++j < arr.length; arr[j - 1] = arr[j]) ;
arr.pop();
}
}
// или
arr.reduceRight((_, n, i, a) => n ? a[i] = i : a.splice(i, 1), 0);
// или
arr.splice(0, arr.length, ...любое_выражение_с_map/filter_или_reduce_из_показанных_выше);
// или
arr.length -= arr.reduce((acc, n, i, a) => (
a[i - acc] = i,
acc + !n
), 0);
data: JSON.stringify({ action: 'get_genres' })json_decode($_POST['action'])json_decode(file_get_contents('php://input'), true)['action']
<button data-move="-10,0">left</button>
<button data-move="10,0">right</button>
<button data-move="0,-10">up</button>
<button data-move="0,10">down</button>
<button data-move="10,10">right down</button>
<button data-move="20,-5">fast right slow up</button>$(document).on('click', '[data-move]', function() {
const [ dx, dy ] = this.dataset.move.split(',').map(Number);
$('#overlay')
.css('left', (i, val) => `${parseInt(val) + dx}px`)
.css('top', (i, val) => `${parseInt(val) + dy}px`);
});
// или, к чёрту jquery
document.addEventListener('click', e => {
const { move } = e.target.dataset;
if (move) {
const block = document.querySelector('#overlay');
const { left, top } = getComputedStyle(block);
const [ dx, dy ] = move.split(',').map(n => +n);
block.style.left = parseInt(left) + dx + 'px';
block.style.top = parseInt(top) + dy + 'px';
}
});
v-for="post in posts.slice(0, определённое количество)"
const $block = $('.block_to_add').clone();
$('.click_to_add_block').click(function() {
$(this).before($block.clone());
});А подскажите, как удалить один из блоков по клику на другую кнопку?
$(document).on('click', '.delete', function() {
$(this).parent().remove();
});<button class="delete">удалить</button>
v-show="showDocs". Обработка клика станет выглядеть так: @click="showDocs = !showDocs".style.display вовсе не none, а пустая строка (скорее всего - вы ведь элемент через css изначально скрываете, да?).Так не получиться, так как вывожу элементы в цикле v-for.