Three more features of Spry 1.4: removeClassName, addClassName, getNodeText

Let’s take a quick look at three more features in Spry 1.4. First lets take a look at remove and addClassName. These two functions will either remove, or apply, a CSS style to an element. So consider this element:

<div id="test">This is the test content that will be changing.</div>

To apply a CSS style to this element, you can use this code:

Spry.Utils.addClassName('test','someCSS');

Obviously removeClassName will remove the item.

The last new function I’ll discuss is getNodeText(). As you can probably guess, it returns the text inside an element. Using the same div above, the following code:

var str = Spry.Utils.getNodeText($('test'));

will set str equal to: This is the test content that will be changing.

For an example of all three, check out this demo Be sure to view source.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments