domnom
v0.2.1
Published
A limited collection of JavaScript DOM prototype extensions.
Downloads
1
Maintainers
Readme
domnom
A limited collection of JavaScript DOM prototype extensions.
Installation
npm install domnom
Usage
Include the script.
<script src="domnom.min.js"></script>
Use familiar DOM syntax.
document.querySelector('.comment').addEventListener('keyup', 'keydown', key_handler);
Building
npm install
npm run build
API Reference
addEventListener(...type, listener, [options], [useCapture]) ⇒ EventTarget
- allows adding the same listener for multiple event types in a single call
- allows chaining multiple calls
- overrides EventTarget.addEventListener
| Param | Type | Description | | --- | --- | --- | | ...type | string | One or more strings representing the event types to listen for. | | listener | function | | | [options] | object | | | [useCapture] | boolean | |
element.addEventListener('click', click_handler);
element.addEventListener('keyup', 'keydown', keypress_handler);
xhr.addEventListener('error', 'abort', interruption_handler);
element
.addEventListener('keyup', keyup_handler)
.addEventListener('keydown', keydown_handler);
removeEventListener(...type, listener, [options], [useCapture]) ⇒ EventTarget
- allows removing the same listener for multiple event types in a single call
- allows chaining multiple calls
- overrides EventTarget.removeEventListener
| Param | Type | Description | | --- | --- | --- | | ...type | string | One or more strings representing the event types to remove the listener for. | | listener | function | | | [options] | object | | | [useCapture] | boolean | |
element.removeEventListener('click', click_handler);
element.removeEventListener('keyup', 'keydown', keypress_handler);
xhr.removeEventListener('error', 'abort', interruption_handler);
input_element
.removeEventListener('keyup', keyup_handler)
.removeEventListener('keydown', keydown_handler)
.blur();
"activeelementchange"
An event dispatched by the document object whenever its activeElement property changes.
document.addEventListener('activeelementchange', function(event) {
console.log(document.activeElement);
});
document.onactiveelementchange = function(event) {
console.log(document.activeElement);
});