Skip to content
Ryc O'Chet edited this page Jun 3, 2018 · 1 revision
- NOTE: This documentation is for Velocity v2.

Command - Property

The "property" command allows you to set or get a property on an element while maintaining Velocity's internal cache. The "style" command is actually a synonym for this.

Getting

When you use more than one element it will return an array, and when you use more than one property it will return an object with each key being one of the property names. These can be combined to return an array of objects.

Setting

When you set any values you get a Velocity result which can be used to chain, this allows you to chain things with (and from) other animations.

element.velocity("property", "opacity", 0.5);
element.velocity("property", { opacity: 0.5, height: "10em" });

var height = element.velocity("property", "height");
// = "25px"

var height = elementList.velocity("property", "height");
// = [ "25px", ... ]

var widthHeight = element.velocity("property", ["width", "height"]);
// = { width: "25px", height: "25px" }

var widthHeight = elementList.velocity("property", ["width", "height"]);
// = [ { width: "25px", height: "25px" }, ... ]