form.addEventListener('submit', (e) => {
e.preventDefault();
const formData = new FormData(form);
formData.append('someField', someValue);
// ...
});
function getTextInComments(el) {
return [...el.childNodes].reduce((acc, curr) => {
if (curr.nodeType === Node.ELEMENT_NODE) {
acc.values.push(...getTextInComments(curr));
} else if (curr.nodeType === Node.COMMENT_NODE) {
acc.isComment = !acc.isComment;
} else if (curr.nodeType === Node.TEXT_NODE && acc.isComment) {
acc.values.push(curr.textContent);
}
return acc;
}, {
values: [],
isComment: false
}).values;
}
const arr = getTextInComments(document.querySelector('.box'));
document.querySelectorAll('div label').forEach((l) => {
l.parentNode.insertBefore(l, l.previousElementSibling);
});
const $items = $('.order__desc');
$items.click(function() {
$('.order__inner').eq($items.index($(this))).show();
});
button:focus + div {
display: block;
}
let arr = [ 'nameOneItem' : 'Name one', 'nameTwoItem' : 'Name two' ];
let arr = [
'Name one',
'Name two'
];
let obj = {
'nameOneItem' : 'Name one',
'nameTwoItem' : 'Name two'
};
let out = '';
let arr = Object.values(obj);
for (let i = 0; i < arr.length; i++ ) {
out += '<span>' + arr[i] + '</span>';
}