Насколько он сложен вообще?
Много ли отличии?
.dropdown {
display: none;
}
.dropdown.show {
display: block;
}
const headerSelector = '.tabs__head';
const contentSelector = '.dropdown';
const activeClass = 'show';
// делегирование, назначаем обработчик клика один раз для всех хедеров;
// контент, соответствующий нажатому хедеру, находим через значение атрибута href
document.addEventListener('click', ({ target: t }) => {
const header = t.closest(headerSelector);
if (header) {
document.querySelectorAll(contentSelector).forEach(function(n, i) {
n.classList[n === this ? 'toggle' : 'remove'](activeClass);
}, document.querySelector(header.attributes.href.value));
}
});
// или, назначаем обработчик клика каждому хедеру индивидуально;
// контент, соответствующий нажатому хедеру, определяем по равенству индексов
const headers = document.querySelectorAll(headerSelector);
const contents = document.querySelectorAll(contentSelector);
headers.forEach(n => n.addEventListener('click', onClick));
function onClick() {
const index = Array.prototype.indexOf.call(headers, this);
contents.forEach((n, i) => n.classList[i === index ? 'toggle' : 'remove'](activeClass));
}
DG.then
. TEXT_WORDS = []
index = 0
for word in TEXT.split():
index = TEXT.index(word, index)
TEXT_WORDS.append((word, index))
index += len(word)
ul ul {
display: none;
}
input[type="radio"]:checked ~ ul {
display: block;
}
class App extends React.Component {
state = {
isTimerActive: false,
}
setTimerActive = isTimerActive => {
this.setState(() => ({ isTimerActive }));
}
onClick = () => {
this.setTimerActive(true);
setTimeout(this.setTimerActive, 60000, false);
}
render() {
const { isTimerActive } = this.state;
return(
<button disabled={isTimerActive} onClick={this.onClick}>
{isTimerActive ? 'отправлено' : 'отправить повторно'}
</button>
);
}
}
$('.price_tabs-content button').click(function() {
const $this = $(this);
const on = $this.siblings('p').toggleClass('on').hasClass('on');
$this.text(on ? 'Закрыть' : $this.data('text'));
}).each((i, n) => $(n).data('text', $(n).text()));
$('.price_tabs-content button').click(function() {
$(this).hide().next().show().end().prev().addClass('on');
}).after('<button>Закрыть</button>').next().hide().click(function() {
$(this).hide().prev().show().prev().removeClass('on');
});
watch: {
isAdaptive: {
immediate: true,
handler(val) {
this.$emit('adaptivity-toggled', val);
},
},
},
<Navigation @adaptivity-toggled="onAdaptivityToggled" />
methods: {
onAdaptivityToggled(e) {
console.log(e); // ну вот и всё
},
},