Get started with dom4 CDN
MIT licensed
DOM4 JS: W3C DOM Level 3 API extension, offering functional, object-oriented document manipulation.
Tags:- DOM
- Level 4
- classList
- CustomEvent
- matches
- DOM4
Stable version
Copied!
How to start using dom4 CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with dom4 CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/dom4/2.1.6/dom4.js"></script>
</head>
<body>
<button id="myButton">Click me</button>
<script>
document.addEventListener('DOMContentLoaded', function() {
const button = document.querySelector('#myButton');
const observer = new DOMMutationObserver(function(mutationsList, observer) {
if (mutationsList[0].type === 'childList') {
console.log('A new child has been added to the button:', mutationsList[0].target.childNodes[0]);
}
});
observer.observe(button, { childList: true, subtree: true });
button.addEventListener('click', function() {
const newElement = document.createElement('span');
newElement.textContent = 'New child';
button.appendChild(newElement);
});
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!