Spry

Selector functions

You can use the following common functions with the Spry Element Selector. There is also an option for a custom function.

Function

Description

Syntax

addClassName

Appends the specified class name to all the matching elements.

Spry.$$("element selector").addClassName("className");

addEventListener

Adds a listener for each matching element for the specified event.

Spry.$$("element selector").addEventListener(eventType, handler, capture);

forEach

Runs the specified function for each matching element. The 'forEach' function allows for any javascript to be run within it.

Spry.$$("element selector").forEach(myFunction);

removeAttribute

Removes the specified attribute from all matching elements.

Spry.$$("element selector").removeAttribute("attribute");

removeEventListener

Removes the listener on each matching element.

Spry.$$("element selector").removeEventListener(eventType, handler, capture);

removeClassName

Removes the specified class name from all the matching elements.

Spry.$$("element selector").removeClassName("className");

setAttribute

Adds the specified attribute with the specified value to all matching elements.

Spry.$$("element selector").setAttribute("attribute","value");

setProperty

Sets a property on an object.

Spry.$$("element selector").setProperty("property","value");

setStyle

Sets the specified styles to the element.

Spry.$$("element selector").setStyle("width:30px;color:#FF00FF;");

toggleClassName

Looks for the specified class name. If it does not exist on the element, it will add it. If it is already there, it will remove it.

Spry.$$("element selector").toggleClassName("className");

Note: Using setAttribute() to set a namespaced attribute (like spry:region) on elements, results in the namespace being dropped in Safari 2.0 browsers. That is, setting an attribute of "spry:region" on an element results in an attribute of "region" being added to the element in Safari 2.0. This bug appears to have been fixed in Safari 3.0.

Comments are no longer accepted for this version of the product. Please pose your questions in the Spry forum at http://forums.adobe.com/community/labs/spry.