A
Size: a a a
A
A
someParentElement.appendChild(newElement);
setTimeout(()=>newElement.remove(), 2500);
IS
IS
const deleteChildWhenAppearsAfterTimeout = (parentSelector, nodeChecker, timeout) => {
const parent = document.querySelector(parentSelector);
const observer = new MutationObserver(mutationsList => {
mutationList.forEach(mutation => {
const element = mutation.addedNodes?.find(nodeChecker);
if (element) {
setTimeout(() => element.remove(), timeout);
observer.disconnect();
}
});
});
observer.observe(parent, { childList: true });
};
//example
deleteChildWhenAppearsAfterTimeout('body', () => true, 500)
I
IS
I
IS
arr.findIndex(el => el.includes(word))
I
IS
I
IS
I
IS
I
IS
arr.findIndex(el => el.indexOf(word) !== -1)
IS
I
IS
function findIndexByWord(arr, word) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].indexOf(word) > 0 ) {
return i
}
}
return -1
}
IS