remove() или removeChild()
Может я что-то упустил читая книгу, но можете объяснить :
function showNotification(option) { var notification = document.createElement('div'); notification.style.top = option.top; notification.style.right = option.right; notification.innerHTML = option.html; notification.classList.add(option.className, 'notification'); document.body.appendChild(notification); setTimeout(function() { document.body.removeChild(notification); }, 1500); } var number = 1; setInterval(function() { showNotification({ top: 10, right: 10, html: 'Привет ' + number++, className: 'welcome' }); }, 2000); Есть ли разница между remove() и removeChild, и что лучше для производительности, скрыть элемент из DOM или все таки удалить?* |
Цитата:
Очень развёрнутый ответ написан в книге: Учебник JavaScript » Добавление и удаление узлов Element.remove() НЕ поддерживается всеми обозревателями сети (Chrome & Firefox 23+, Opera 10+, and Safari 7+), и не для всех версий Internet Explorer… и даже IE11. |
Спасибо. А что насчет вопроса про производительность?
|
Часовой пояс GMT +3, время: 04:47. |