domQ
Github
Plugins
NPM
Report Issue
Search…
Intro
Getting Started
Collection Methods
Animation
Attributes
Collection
CSS
Data
Dimensions
Effects
Events
Forms
Manipulation
Offset
Traversal
Static Methods
String
Utilities
Type Checking
Developer Guides
Migration Guide
Extending domQ
Change Log
Powered By
GitBook
Extending domQ
domQ can be extended, adding custom methods to domQ collections or custom static methods to the domQ object.
If you're writing JavaScript the way to do it is exactly the same as what you'd do for extending jQuery
Collection Method
This is how you can add an hypothetical
foo
method to domQ collections:
Function Declaration
Vanilla Javascript
ES Module
1
(
function
(
window
)
{
2
window
.
domQ
.
fn
.
foo
=
function
()
{
3
return
this
;
4
};
5
}
)(
window
);
Copied!
1
import
domQ
from
"domQ"
;
2
3
domQ
.
fn
.
foo
=
function
()
{
4
return
this
;
5
};
Copied!
Function Callback / Usage
1
domQ('*').foo();
Copied!
Static Method
This is how you can add an hypothetical
calcNumbers
static method to the Cash object:
Function Declaration
Vanilla Javascript
ES Module
1
(
function
(
window
)
{
2
window
.
domQ
.
calcNumbers
=
function
(
number1
,
number2
)
{
3
return
(
number1
+
number2
);
4
};
5
}
)(
window
);
Copied!
1
import
domQ
from
"domQ"
;
2
3
domQ
.
calcNumbers
=
function
(
number1
,
number2
)
{
4
return
(
number1
+
number2
);
5
};
Copied!
Function Callback / Usage
1
domQ
.
calcNumbers
(
10
+
2
);
// returns as 12
Copied!
Developer Guides - Previous
Migration Guide
Next
Change Log
Last modified
1yr ago
Export as PDF
Copy link
Contents
Collection Method
Function Declaration
Function Callback / Usage
Static Method
Function Declaration
Function Callback / Usage