Skip to content

tvrzna/nunjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nunjs

[ˈnuɲeθ]

Very small jQuery-like library with only few functions with emphasis on total size.

Functions

addClass

since 0.0.1

addClass(name) -> self

Add class to each element.

ajax

since 0.0.2

ajax(options) -> xhttp

since 0.0.4

ajax(url, options) -> xhttp

Performs an Ajax request.

async boolean, default true

complete function

data string

error function(xhttp)

headers {}

success function(responseText, xhttp)

type string, default GET

url string

get

since 0.0.4 get(url, options) -> xhttp

Shortcut for ajax request with GET type.

post

since 0.0.4 post(url, options) -> xhttp

Shortcut for ajax request with POST type.

put

since 0.0.4 put(url, options) -> xhttp

Shortcut for ajax request with PUT type.

appendTo

since 0.0.3

appendTo(selector) -> collection

Appends collection as last into each element found by selector.

attr

since 0.0.1

attr(attribute_name) -> value

attr(attribute_name, value) -> self

Read or set DOM attribute of each element. If value is not defined, it returns value of first element, otherwise it sets attribute to each element.

click

since 0.0.1

click() -> self

click(trigger) -> self

If trigger is not defined, it performs click on each element, otherwise it adds event listener.

clone

since 0.0.3

clone() -> collection

Performs deep copy of each element and return clones as collection.

each

since 0.0.1

each(function (index, element) { ... }) -> self

Iterates elements of the collection. Function arguments are optional since current element is accessible with this keyword.

find

since 0.0.1

find(selector) -> collection

Finds elements by selector in current children collection of elements.

hasClass

since 0.0.1

hasClass(name) -> boolean

Checks if any element in collection has specified class.

hasEvent

since 0.0.4

hasEvent(name) -> boolean

Checks if first element in collection has specified event.

hide

since 0.0.1

hide() -> self

Hides elements in collection by setting display to none.

html

since 0.0.3

html() -> string

html(content) -> self

Read or set inner HTML of each element. If content is not defined, it returns HTML of first element, otherwise it sets HTML to each element.

is

since 0.0.1

is(selector) -> boolean

Checks first element of collection matches the CSS selector.

insertAfter

since 0.0.3

insertAfter(selector) -> collection

Inserts copy of collection after each element found by selector.

insertBefore

since 0.0.3

insertBefore(selector) -> collection

Inserts copy of collection before each element found by selector.

nunjs

since 0.0.3

nunjs -> version

Not a function, just a property, that signals current version of library.

off

since 0.0.1

off(event) -> self

off(event, trigger) -> self

Detach event handlers added with on. If trigger is defined, it detach only this one specific listener, otherwise it detach all of event type.

on

since 0.0.1

on(event, trigger) -> self

Attach event handler to all elements in collection.

parent

since 0.0.1

parent() -> collection

parent(selector) -> collection

If selector is not defined, it returns collection of parents of all elements, otherwise it returns collection of parents (on any level) matching selector.

prependTo

since 0.0.3

appendTo(selector) -> collection

Appends collection as first into each element found by selector.

prop

since 0.0.3

prop(property_name) -> value

prop(property_name, value) -> self

Read or set DOM property of each element. If value is not defined, it returns property of first element, otherwise it sets property to each element.

ready

since 0.0.1

ready(trigger) -> self

Attach an event handler for the DOMContentLoaded, that is fired when the page is ready.

remove

since 0.0.3

remove() -> void

Removes all elements in the collection.

removeAttr

since 0.0.3

removeAttr(name) -> self

Removes specified attribute from all elements in the collection.

removeClass

since 0.0.1

removeClass(name) -> self

Removes specified class from all elements in the collection.

removeProp

since 0.0.3

removeProp(property_name) -> self

Removes specified property from all elements in the collection.

show

since 0.0.1

show() -> self

Restores default value of display on all elements.

submit

since 0.0.1

submit() -> self

Performs submit.

text

since 0.0.1

text() -> string

text(content) -> self

Gets of sets the text content of elements in the collection. If no content is defined, it returns the text contents of all elements, otherwise it replaces the text content of each elements.

toggle

since 0.0.1

toggle() -> self

Toggles between showing and hiding of the elements based on their on display property of first element in collection.

val

since 0.0.2

val() -> string

val(value) -> self

Gets or sets value of form control. If no value is defined, it returns value of first element, otherwise it sets value for all elements in collection.

About

Very small jQuery-like library with only few functions with emphasis on total size.

Topics

Resources

License

Stars

Watchers

Forks