Home arrow JavaScript arrow Page 4 - JavaScript Objects: More on String Methods
JAVASCRIPT

JavaScript Objects: More on String Methods


Welcome back to my series covering JavaScript Objects. In the last issue we discussed the Object String properties and some of the Object String methods. In this episode we will continue our discussion of the Object String methods and how to use them.

Author Info:
By: James Payne
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
January 22, 2008
TABLE OF CONTENTS:
  1. · JavaScript Objects: More on String Methods
  2. · The CharAt() Method
  3. · Working with the ConCat() Method
  4. · The FontColor() Method
  5. · FromCharCode() Method
  6. · The LastIndexOf() Method

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
JavaScript Objects: More on String Methods - The FontColor() Method
(Page 4 of 6 )

To change the color of your text, just use the FontColor() method. We covered Colors a few tutorials back, and you can find a sheet with color codes in that article. Here is how you write the code to change your text color:


<html>

<body>


<script type="text/javascript">


var smash="ARGH! HULK SMASH! HULK SMASH GOOD!!!"


document.write("<p>Look, green text!: " + smash.fontcolor("Green") + "</p>")

</script>


</body>

</html>

This would display the following text:

  Look, green text!: ARGH! HULK SMASH! HULK SMASH GOOD!!!

The FontSize() Method

Just as we can change the color of text, we can change the size as well. I know, it's a real shocker. We do this with the FontSize() method:


<html>

<body>


<script type="text/javascript">


var smash="Hulk SMASH!"

document.write("<p>" + smash.fontsize(16) + "</p>")


</script>


</body>

</html>

This prints out:

Hulk SMASH!


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials