|
|
JavaScript string objectJavaScript string object we can use with its different properties and methods to get various string formats and string types. We will discuss with some examples for better understanding.
Let us first declare a new string object like this.
<script type="text/javascript">
my_string= new String("Welcome to plus2net.com");
</script>
Length property to get the length of the string
It gives the total length of the string including blank spaces present in a string.
document.write(my_string.length);
Output: 23
Making the string Bold
document.write(my_string.bold());
Declaring the font size of the string
document.write(my_string.fontsize(6));
Making the string blink ( not work in IE )
document.write(my_string.blink());
Making TT type font with fixed
document.write(my_string.fixed());
Making the font color of the string
document.write(my_string.fontcolor("blue"));
Changing to Italic font
document.write(my_string.italics());
Adding a link to the string by link
document.write(my_string.link("http://www.plus2net.com"));
Making the font style strike out
Demo script using strike property
document.write(my_string.strike());
Getting a substring with start and end points
document.write(my_string.substring(10,15));
Making sub script
document.write(my_string.sub());
Found anything wrong or wants to improve the code by adding more features? Post your short comment here or use the Forum
| |
| |
|
|
|
|
|