Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tinyDOM
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Louis
tinyDOM
Commits
0bfbc61a
Commit
0bfbc61a
authored
10 years ago
by
Commander-lol
Browse files
Options
Downloads
Patches
Plain Diff
Create README.md
parent
5366ba2b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+38
-0
38 additions, 0 deletions
README.md
with
38 additions
and
0 deletions
README.md
0 → 100644
+
38
−
0
View file @
0bfbc61a
tinyDOM
=======
tinyDOM is a fairly simple jquery alternative that works in a similar way, making it easy to find and modify DOM elements.
It's accessed through the symbol 'μ' or the alias 'mu' where unicode isn't available (both can be used any time).
Basic Usage
-----------
There are two different categories of tinyDOM functions - utility functions and DOM manipulation functions. The former are
invoked directly on the mu object and generally work on their paramaters, such as the 'merge' function for merging two JSON
objects:
```
javascript
μ
.
merge
(
objectA
,
objectB
);
// objectA will contain all of the properties of both objectA and objectB
```
and the 'exists' function for simplifying existence checks:
```
javascript
μ
.
exists
(
objectC
);
// Returns false if objectC is null or if typeof(objectC) returns 'undefined'
```
DOM manipulation
----------------
The second category of tinyDOM functions operate on DOM elements via a mu object, which is created by passing a query selector
to mu. The returned mu object provides methods that make it easier to interact with the DOM elements and also allows you to
call a function on a set of DOM elements via the '.each(fn)' interface. Here's a simple example of attaching an event handler
to all elements with the 'clickable' class:
```
javascript
μ
(
'
.clickable
'
).
on
(
'
click
'
,
function
(){
console
.
log
(
this
);
});
```
It doesn't make sense to perform certain operations on a group, and in those cases the first matched element will be used
as the target of a given function - this might be important in cases where multiple elements will match a query selector.
For example, the '.data(key)' function wouldn't work if it attempted to get data from every element in a set.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment