Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eeue56/elm-query
JQuery for Elm
https://github.com/eeue56/elm-query
Last synced: about 1 month ago
JSON representation
JQuery for Elm
- Host: GitHub
- URL: https://github.com/eeue56/elm-query
- Owner: eeue56
- License: bsd-3-clause
- Created: 2015-11-07T20:27:07.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-09T00:02:50.000Z (about 9 years ago)
- Last Synced: 2024-05-21T12:33:37.958Z (8 months ago)
- Language: Elm
- Homepage:
- Size: 0 Bytes
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-query
Elm-query provides a way of manipulating and querying DOM elements without turning to ports.
## Getting nodes by class
```elm
funnyNodes : List Query.QueryNode
funnyNodes = Query.getAll ".funny"```
## Getting a node by id
```elm
nameNode : Maybe QueryNode
nameNode = Query.get "#name"```
## Seeing if the active element is any of those with a given class
```elm
isAnyFunnyActive : Bool
isAnyFunnyActive =
Query.getAll ".funny"
|> List.filter (Query.isActiveElement)
|> List.isEmpty
|> not```
## Focusing an element
```elm
focused : Effects QueryNode
focused =
case Query.get "#name" of
Just node ->
Query.focus node
|> Effects.task
Nothing -> Effects.none```