Simple DOM selector function
Object
:
The DOM element(s) that were selected
$_
Constructor function
Object
:
KIS object
Change css property name to it's javascript camel case equivalent
String
s
:
the string to convert to camelCase
String
:
the newly camelCased string
Adds an event that returns a callback when triggered on the selected event and selector
$_("#selector").event.add("click", do_something());
Create a custom event
Object
var event = $_("#selector").event.create('foo', {});
Binds an event to a parent object
$_("#parent").delegate(".button", "click", do_something());
Binds a persistent event to the document
$_.event.live(".button", "click", do_something());
Removes an event bound the the specified selector, event type, and callback
$_("#selector").event.remove("click", do_something());
Trigger an event to fire
object
event
:
boolean
$_("#my_id").trigger('click');
DOM
Dom manipulation module
.addClass(className)
Adds a class to the element(s) specified by the current selector
Adds a class to the element(s) specified by the current selector
string
className
:
css class name to add to the selected element(s)
void
.append(htm)
Adds to the innerHTML of the current element, after the last child.
Adds to the innerHTML of the current element, after the last child.
string
htm
:
$_("ul").dom.append("<li></li>"); // Adds an li element to the end of the selected ul element
.attr(name, [value])
Sets attributes on element(s) specified by the current selector, or, if name is not specified, returns the value of the attribute of the element specified by the current selector.
Sets attributes on element(s) specified by the current selector, or, if name is not specified, returns the value of the attribute of the element specified by the current selector.
string
name
:
[undefined]
value
:
.css(property, [value], prop, val)
Sets or retrieves a css property of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the css property on the current element.
Accepts either key/value arguments, or an object with multiple key/value pairs.
Sets or retrieves a css property of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the css property on the current element.
Accepts either key/value arguments, or an object with multiple key/value pairs.
$_('#foo').dom.css('border', 0);
$_('#foo').dom.css({background:'#000', color:'#fff'});
.hide
Hides the element(s) specified by the current selector
Hides the element(s) specified by the current selector
void
.html([htm])
Sets or gets the innerHTML propery of the element(s) passed
Sets or gets the innerHTML propery of the element(s) passed
[undefined]
htm
:
.prepend(htm)
Adds to the innerHTML of the selected element, before the current children
Adds to the innerHTML of the selected element, before the current children
string
htm
:
$_("ul").dom.append("<li></li>"); // Adds an li element to the beginning of the selected ul element
.removeClass(className)
Removes a class from the element(s) specified by the current selector
Removes a class from the element(s) specified by the current selector
string
className
:
css class name to remove from the selected element(s)
void
.show([type])
Shows the element(s) specified by the current selector. if type is specified, the element will have it's style property set to "display:[your type]". If type is not specified, the element is set to "display:block".
Shows the element(s) specified by the current selector. if type is specified, the element will have it's style property set to "display:[your type]". If type is not specified, the element is set to "display:block".
[string
]
type
:
void
.text([value])
Sets or retrieves the text content of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the current element
Sets or retrieves the text content of the element specified by the current selector. If a value is passed, it will set that value on the current element, otherwise it will return the value of the current element
[undefined]
value
:
Wrapper for localstorage / sessionstorage data serialization. Each method has a boolean parameter, that when set as true switches the method to use sessionStorage rather than the default localStorage.
.clear(session, sess)
Removes all values from the same domain storage
Removes all values from the same domain storage
bool
session
:
.getAll(session, sess)
Returns an object of all the raw values in storage
Returns an object of all the raw values in storage
bool
session
:
Object
.remove(key, session, sess)
Removes the specified item from storage
Removes the specified item from storage
string
key
:
bool
session
:
.set(key, value, session, sess)
Puts a value into localstorage at the specified key, and JSON-encodes the value if not a string
Puts a value into localstorage at the specified key, and JSON-encodes the value if not a string
string
key
:
mixed
value
:
bool
session
:
Current selector object
Event Listener module
Send an ajax request
string
url
:
The url to retrieve
[Object
]
options
:
Request type parameters
[Object
]
data
:
Request data
Promise
Sends a GET type ajax request
Sends a POST type ajax request
Sends a PUT type ajax request
Iterates over a $_ object, applying a callback to each item
function
callback
:
iteration callback
void
$_('form input').each(function(item) { alert(item) });
Sends a DELETE type ajax request
Retrieves the type of the passed variable
Object to test
string
:
variable type
$_.type([]); // Returns 'array'
DOM
Dom manipulation module
Event
Event api wrapper
Kis JS Keep It Simple JS Library Copyright Timothy J. Warren License Public Domain Version 0.10.1
Ajax
Module for making ajax requests
Store
Wrapper for local / sessionstorage