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:


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.

Like This?

If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can also subscribe to the email feed to get notified of new posts.