<div>
<span>{{ item.questions[index]['description'] }}</span>
<span v-if="item.questions[index]['answer'] == 2">Да</span>
<span v-if="item.questions[index]['answer'] == 1">Нет</span>
</div><div v-for="n in item.questions">
<span>{{ n.description }}</span>
<span>{{ n.answer | answer }}</span>
</div>filters: {
answer: val => [ 'Нет', 'Да' ][val - 1],
...
#list-case вы назначаете обработчики клика всем существующим .img и .show, а не только свежесозданным. Если срабатывает два (или четыре, или шесть, или...) обработчика, которые выполняют toggleClass, то конечное состояние от начального отличаться не будет. Отсюда ваше кажущееся "не работает"..case, делайте это один раз, используя делегирование:$('#list-case')
.on('click', '.img', function() {
$(this).closest('.case').remove();
})
.on('click', '.show', function() {
$(this).toggleClass('none').closest('.case').find('.case-bottom').toggleClass('invise');
});
const placeholders = [ 'hello, world!!', 'fuck the world', 'fuck everything' ];
const delay = 200;
const input = document.querySelector('input');function interval(arr, delay, callback) {
let i = -1;
return arr.length
? setInterval(() => callback(arr[i = -~i % arr.length]), delay)
: null;
}
const intervalId = interval(placeholders, delay, n => input.placeholder = n);
// хотим остановить, делаем так: clearInterval(intervalId);function interval(arr, delay, callback) {
let timeoutId = null;
arr.length && (function next(i) {
timeoutId = setTimeout(() => {
callback(arr[i]);
next((i + 1) % arr.length);
}, delay);
})(0);
return () => clearTimeout(timeoutId);
}
const stop = interval(
placeholders,
delay,
Element.prototype.setAttribute.bind(input, 'placeholder')
);
// хотим остановить, делаем так: stop();
render: val => val
? <Tag color="success">Активен</Tag>
: <Tag color="default">Не активен</Tag>
return false;toggle дважды начинает срабатывать
const comparators = [
[ 'city', (itemVal, filterVal) => itemVal === filterVal ],
[ 'title', (itemVal, filterVal) => itemVal.includes(filterVal) ],
[ 'type', (itemVal, filterVal) => itemVal.includes(filterVal) ],
];
const filteredArr = arr.filter(n => comparators.every(([ k, f ]) => f(n[k], filter[k])));
document.querySelectorAll('.group-options__item').forEach(n => {
const input = (n.closest('.group-options') ?? n).querySelector('[data-prop]');
if (input) {
input.checked = true;
}
});
function getStrings(str) {
const str1 = str.match(/\(.+?\)/g)?.find(n => /\d/.test(n)) ?? '';
return {
str1: str1.slice(1, -1),
str2: str.replace(str1, ''),
};
}
const getVal = option =>
option.value;
// или
// option.getAttribute('value');
// option.attributes.value.value;const addText = (option, text) =>
option.text += text;
// или
// option.textContent = option.textContent.concat(text);
// option.innerText = `${option.innerText}${text}`;
// option.append(text);
// option.insertAdjacentText('beforeend', text);
// option.appendChild(document.createTextNode(text));
// option.insertBefore(new Text(text), null);const addValToText = option => addText(option, getVal(option));Array.prototype.forEach.call(select, addValToText);
// или
select.querySelectorAll('option').forEach(addValToText);
// или
for (const n of select) {
addValToText(n);
}
// или
for (let i = 0; i < select.options.length; i++) {
addValToText(select.options.item(i));
}
// или
(function add(i, n = select.children[i]) {
if (n) {
addValToText(n);
add(i + 1);
}
})(0);
// или
const add = n => n && (addValToText(n), add(n.nextElementSibling));
add(select.firstElementChild);
values: Array(height).fill(Array(width).fill(null))
values: Array.from({ length: height }, () => Array(width).fill(null))const initialState = {
player: 'X',
cells: Array.from({ length: 3 }, () => Array(3).fill(null)),
};
const store = createStore((state = initialState, action) => {
switch (action.type) {
case 'MOVE':
return {
...state,
player: state.player === 'X' ? 'O' : 'X',
cells: state.cells.map((row, iRow) => iRow === action.location[0]
? row.map((cell, iCol) => iCol === action.location[1] ? state.player : cell)
: row
),
};
case 'RESET':
return initialState;
default:
return state;
}
});const Board = connect(({ cells }) => ({ cells }))(({ cells }) => (
<div class="board">
{cells.map((row, iRow) =>
<div className="row">
{row.map((cell, iCol) =>
<Cell location={[ iRow, iCol ]} value={cell} />
)}
</div>
)}
</div>
));const Cell = connect(null, (dispatch, { location }) => ({
onClick: () => dispatch({ type: 'MOVE', location }),
}))(({ value, onClick }) => (
<div className="cell">
<button onClick={onClick} disabled={value !== null}>
{value}
</button>
</div>
));const Reset = connect(null, dispatch => ({
reset: () => dispatch({ type: 'RESET' }),
}))(({ reset }) => (
<button onClick={reset}>RESET</button>
));const App = () => (
<Provider store={store}>
<Reset />
<Board />
</Provider>
);
v-scroll-text="{ selector: '.source-label', speed: 10 }"scrollText(el, { value: { selector, speed } }) {
...