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

This post is more than 2 years old.

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.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by John Ramon posted on 12/18/2006 at 8:49 AM

Sweet moves Ray, I've been messing with Google Maps and I really thing I could get some use from Spry. I gots to brush up on my javascript.

Comment 2 by Raymond Camden posted on 12/18/2006 at 8:51 AM

Trust me - my JS was rusty as well. AJAX is bringing it back.

Comment 3 by Lola LB posted on 12/18/2006 at 7:59 PM

I never really liked JavaScript - I just can't stand the syntax. But now I'm going to have to really bone up on it.

Comment 4 by Tony Petruzzi posted on 12/18/2006 at 11:28 PM


Shameless jQuery plug

I HATED, HATED JavaScript also. Then I found jQuery and it brought back the fun! It's easy to learn, powerful and the community is awesome. Take a look if you haven't heard of it.

Comment 5 by Roger Benningfield posted on 12/20/2006 at 12:22 AM

Y'know, I really disliked the initial releases of Spry... the stuff it made easy wasn't really relevant to me, and required some ugly HTML.

But now they're getting into some things I can really use, and I'm slightly excited.

Comment 6 by Steve posted on 12/20/2006 at 10:55 PM

I am having trouble with a condition ( This is only part of a site that is for people to use to predict the bowl games, and I want to make it so that if their prediction is right, the text is green, and if not red. Any suggestions on how to go about doing this?

Comment 7 by Raymond Camden posted on 12/21/2006 at 2:47 AM

You want to use conditionals. Here is a slightly older example of that:

It is pretty simply in Spry.