$(document).click(function(e) {
if (!$panel.has(e.target).length && $panel.hasClass('visible')) {
hidePanel();
}
});
const ip = str.split(':', 1)[0];
const ip = str.slice(0, str.indexOf(':'));
const ip = str.match(/[\d.]+/).pop();
const ip = str.replace(/:.+$/, '');
const [ ip ] = /.+(?=:)/.exec(str);
animation-delay
, а для "задержки" указываете в keyframes
промежуток без изменения значения:<div class="wrapper">
<div class="block">hello, world!!</div>
<div class="block">fuck the world</div>
<div class="block">fuck everything</div>
</div>
.wrapper {
width: 150px;
height: 20px;
font-size: 16px;
border: 1px solid #000;
overflow: hidden;
position: relative;
}
@keyframes movingTopToBottom {
0% {
top: 55px;
}
40%, 60% {
top: 0px;
}
100% {
top: -55px;
}
}
.block {
animation: movingTopToBottom 6s linear infinite;
position: absolute;
}
.block:nth-child(1) { animation-delay: 0s; }
.block:nth-child(2) { animation-delay: -4s; }
.block:nth-child(3) { animation-delay: -2s; }
@focus="disabled = true"
@blur="disabled = false"
@mousedown="disabled = !disabled"
formMeta: [
{ type: '...', props: { ... } },
{ type: '...', props: { ... } },
....
],
<div v-for="{ type, props } in formMeta" class="form-item">
<component :is="type" v-bind="props"></component>
</div>
fieldset > .ui-checkboxradio-label {
width: 100%;
box-sizing: border-box;
text-align: left;
}
const plainToNested = (source, target = {}) =>
Object.entries(source).reduce((acc, [ path, val ]) => {
const keys = path.split('.');
const key = keys.pop();
keys.reduce((p, c) => p[c] = p[c] || {}, acc)[key] = val;
return acc;
}, target);
const buttonSelector = '.one-click-button';
const dataAttr = 'id';
const input = document.querySelector('#one_b_id');
const getId = el => el.dataset[dataAttr];
// или
const getId = el => el.getAttribute(`data-${dataAttr}`);
// или
const getId = el => el.attributes['data-' + dataAttr].value;
document.addEventListener('click', e => {
const button = e.target.closest(buttonSelector);
if (button) {
input.value = getId(button);
}
});
document.querySelectorAll(buttonSelector).forEach(function(n) {
n.addEventListener('click', this);
}, e => input.value = getId(e.currentTarget));
Как я могу проверить на наличие в начале строки undefined и удалить её?
str.replace(/^undefined/, '')
. divParent.insertBefore(elems[i].cloneNode(true), null);
divParent.insertBefore(elems[i].cloneNode(true), divParent.firstChild);
// или
divParent.insertAdjacentElement('afterbegin', elems[i].cloneNode(true));
// или
divParent.prepend(elems[i].cloneNode(true));
for (const n of document.querySelectorAll('.basic')) {
n.after(document.createElement('div'));
n.nextSibling.classList.add('parent');
n.nextSibling.innerHTML = '<b>Важная строка</b>';
n.nextSibling.prepend(n);
}
document.querySelectorAll('.basic').forEach(n => {
const html = `
<div class="parent">
${n.outerHTML}
<b>Важная строка</b>
</div>
`;
n.outerHTML = html;
// или
n.insertAdjacentHTML('afterend', html);
n.remove();
// или
n.replaceWith(document.createRange().createContextualFragment(html));
// или
n.replaceWith(...new DOMParser().parseFromString(html, 'text/html').body.childNodes);
});
document.querySelectorAll('.number').forEach(function(n) {
const top = n.getBoundingClientRect().top;
const end = +n.dataset.max;
window.addEventListener('scroll', function onScroll() {
if (window.pageYOffset > top - window.innerHeight / 2) {
this.removeEventListener('scroll', onScroll);
let start = +n.innerHTML;
const interval = setInterval(function() {
n.innerHTML = ++start;
if (start === end) {
clearInterval(interval);
}
}, 5);
}
});
});
JSON.parse
- вы же указали dataType: 'json'
в настройках запроса, так что data уже будет объектом.