1.0.2 • Published 5 years ago
docuget v1.0.2
Docuget
What is Docuget?
Docuget is a wrapper for document.querySelector()
which makes it easy to select elements in the DOM.
Installation
Run the command
npm i docuget
to install Docuget.
Require
Require with this code:
<script src="node_modules/docuget/main.js"></script>
Syntax
$(query);
Where query
is the CSS selector to select the element.
Use #elementID
to select an element by its ID.
Use .elementClass
to select an element by its class.
Use [attribute=value]
to select an element by the value one of its attributes has.
Use element
to select and element by its type.
Returns: the first element that matches the query.
Example
Select an element by its ID and change its text.
$('#myElement').innerHTML = 'Hello World!';
as opposed to:
document.getElementById('myElement').innerHTML = 'Hello World!';
or:
document.querySelector('# myElement').innerHTML = 'Hello World!';