- res.writeHead(200, { 'Content-Type': 'text/plain' });
+ res.writeHead(200, {
+ 'Content-Type': 'text/plain',
+ 'Access-Control-Allow-Origin': '*'
+ });
input.addEventListener('input', event => {
const element = event.target;
const currentValue = element.value;
const preparedValue = currentValue.replace(/\D/g, '');
const start = element.selectionStart;
const end = element.selectionEnd;
if (preparedValue !== currentValue) {
element.value = preparedValue;
element.dispatchEvent(new Event('change', { bubbles: true }));
if (event.inputType === 'insertText') {
const offset = event.data.length;
element.setSelectionRange(start - offset, end - offset);
}
}
});
<div className={`${category} ${accessories}`}>
<div className={clsx(category, accessories)}>
span
, а не a
, и у span
нет href
.- $(this).attr("href").substr(1)
+ $(this).closest("a").attr("href").substr(1)
$('.form').on('submit', function (e) {
e.preventDefault();
const values = {};
$('.form__check').each(function () {
if ($(this).is(':checked')) {
const [name, ...keys] = $(this).attr('name').split('-');
if (name) {
(values[name] ??= []).push(keys.join('-'));
}
}
});
for (const key in values) {
$(`.inputs__value--${key}`).text(values[key].join(','));
}
});
const form = document.querySelector('form');
for (const element of form.elements) {
const wrapper = element.closest('.form_block');
if (wrapper !== null) {
element.addEventListener('blur', (event) => {
if (!wrapper.contains(event.relatedTarget)) {
wrapper.classList.add('dd');
}
});
}
}
tabindex="0"
убрать можно. position: absolute
), скрываете (opacity: 0; visibility: hidden;
). При (:focus
, :focus-within
и :hover
) показываете (opacity: 1; visibility: visible;
). .blur
, если пользователь сфокусирован).