ReadSpeaker Selector Documentation
Overview
ReadSpeaker.q() | Executes when DOM is ready. |
$rs.get() | Select elements using a selector. |
$rs.findIn() | Selects elements within another element. |
$rs.getAttr() | Gets the specified attribute value from the element. |
$rs.setAttr() | Sets an attribute value of a node element. |
$rs.regEvent() | Registers an event on a specified element. |
$rs.unregEvent() | Unregisters an event. |
$rs.addClass() | Adds a class to the element. |
$rs.removeClass() | Removes a class from an element. |
$rs.hasClass() | Checks if an element has a class or not. |
$rs.focus() | Sets focus on the specified element. |
$rs.focusIn() | Bind an event handler to the “focusin” event. |
$rs.focusOut() | Bind an event handler to the “focusout” event. |
Documentation
ReadSpeaker.q()
ReadSpeaker.q( handler )
Description: Executes when the DOM is ready. Send either a block of code wrapped in a
function body or a reference to a function.
Example:
ReadSpeaker.q(function() { alert('DOM is ready!'); });
$rs.get()
$rs.get( selector )
Description: Selects elements using the selector
Return: If only one match, returns it as is, if more than one, returns an array of DOM
elements. If no match, returns empty array.
Example:
$rs.get('#readspeaker_button');
$rs.findIn()
$rs.findIn( 'element', selector)
Description: Selects elements within another element
Return: If one or more matches, returns an array of DOM elements. If no match, returns
empty array.
Example:
$rs.findIn('#readspeaker_button', '.rsbtn'); //Alternative way of doing it is var elm = $rs.get('#readspeaker_button'); $rs.findIn(elm, '.rsbtn');
$rs.getAttr()
$rs.getAttr( 'element', 'attributeName' );
Description: Gets the specified attribute value from the element.
Return: {String} The attribute value
Example:
$rs.getAttr('#readspeaker_button', 'title');
$rs.setAttr()
$rs.setAttr( 'element', 'attributeName', ‘newValue’ );
Description: Sets an attribute value of a node element.
Return: {String} The new value that was set
Example:
$rs.setAttr('#readspeaker_button', 'title', 'Listen to page');
$rs.regEvent()
$rs.regEvent( 'element', 'eventType', handler );
Description: Registers an event on a specified element.
Example:
$rs.regEvent('#readspeaker_button', 'click', function() { alert('Element clicked!'); });
$rs.unregEvent()
$rs.unregEvent( 'element', 'eventType', handler(optional) );
Description: Unregisters an event.
Example:
$rs.unregEvent('#readspeaker_button', 'click');
$rs.addClass()
$rs.addClass( 'element', 'className' );
Description: Adds a class to the element. Does nothing if it already exists. Multiple classes
can be added at once, separated by a space.
Example:
$rs.addClass('#readspeaker_button', 'rs_preserve rs_skip');
$rs.removeClass()
$rs.removeClass( 'element', 'className' );
Description: Removes a class from an element. Does nothing if does not exist. Multiple
classes can be removed at once, separated by a space.
Example:
$rs.removeClass('#readspeaker_button', 'rs_preserve');
$rs.hasClass()
$rs.hasClass( 'element', 'className' );
Description: Checks whether an element has a class or not.
Return: Returns true if the class was found and false otherwise.
Example:
$rs.hasClass('#readspeaker_button', 'rsbtn');
$rs.focus()
$rs.focus( 'element' );
Description: Sets focus on the specified element
Example:
$rs.focus('#readspeaker_button');
$rs.focusIn()
$rs.focusIn( 'element', handler );
Description: Bind a handler to the focusIn event that fires when the specified element
receives focus.
Example:
$rs.focusIn('#readspeaker_button', function() { alert('This element is in focus!'); });
$rs.focusOut()
$rs.focusOut( 'element', handler );
Description: Bind a handler to the focusOut event that fires when the specified element loses
focus.
Example:
$rs.focusOut('#readspeaker_button', function() { alert('This element is no longer in focus!'); });