Returns : *
Returns the property requested. Returns null
if it doesn’t exist.
Details
Returns the property requested. For DOM elements, it will check the following properties in this order (and return it as soon as one is found): the element's inline CSS, the element's .getComputedStyle()
CSS, a property on the element itself like (element.property
), an attribute on the element (like element.getAttribute(property)
). Returns null
if it doesn’t exist.
You can add a second parameter specifying the unit you’d like it to be returned in if you want.
//get the property in the default unit
gsap.getProperty(target, "width");
gsap.getProperty(target, "backgroundColor");
//or pass in a third parameter to define which unit you'd like it back in
gsap.getProperty(target, "width", "em");