WHAT'S NEW?
Loading...

Using HTML Wrappers - fontsize (), italics (), link (), small (), strike (), sub(), sup () in javascript with example - Tech-n-Savvy Blogger


fontsize ()

This method causes a string to be displayed in the specified size as if it were in a <font size="size"> tag.

Syntax

Its syntax is as follows:

string.fontsize( size )

Attribute Details

size: An integer between 1 and 7, a string representing a signed integer between 1 and 7.

Return Value

Returns the string with <font size="size"> tag.



Example

Try the following example.

<html>

<head>

<title>JavaScript String fontsize() Method</title>

</head>

<body>

<script type="text/javascript">


var str = new String("Hello world");


alert(str.fontsize( 3 ));


</script>

</body>

</html>

Output

<font size="3">Hello world</font>


italics ()

This method causes a string to be italic, as if it were in an <i> tag.

Syntax

Its syntax is as follows:

string.italics ( )

Return Value

Returns the string with <i> tag.




Example

Try the following example.


<html>
<head>

<title>JavaScript String italics() Method</title>

</head>

<body>

<script type="text/javascript">

var str = new String("Hello world");

alert(str.italics( ));

</script>

</body>

</html>

Output

<i>Hello world</i>


link ()

This method creates an HTML hypertext link that requests another URL.

Syntax

The syntax for link() method is as follows:

string.link ( hrefname )

Attribute Details

hrefname: Any string that specifies the HREF of the A tag; it should be a valid URL.

Return Value

Returns the string with <a> tag.

Example

Try the following example.


<html>
<head>

<title>JavaScript String link() Method</title>

</head>

<body>

<script type="text/javascript">

var str = new String("Hello world");

var URL = "http://www.tutorialspoint.com";


alert(str.link( URL ));

</script>

</body>

</html>

Output

<a href = “http://www.tutorialspoint.com”>Hello world</a>


small ()

This method causes a string to be displayed in a small font, as if it were in a <small> tag.

Syntax

Its syntax is as follows:

string.small ( )

Return Value

Returns the string with <small> tag.


Example

Try the following example.


<html>

<head>

<title>JavaScript String small() Method</title>

</head>

<body>

<script type="text/javascript">

var str = new String("Hello world");

alert(str.small());

</script>

</body>

</html>

Output

<small>Hello world</small>


strike ()

This method causes a string to be displayed as struck-out text, as if it were in a <strike> tag.

Syntax

Its syntax is as follows:

string.strike ( )

Return Value

Returns the string with <strike> tag.

Example

Try the following example.


<html>
<head>

<title>JavaScript String strike() Method</title>

</head>

<body>

<script type="text/javascript">


var str = new String("Hello world");

alert(str.strike());


</script>

</body>

</html>

Output

<strike>Hello world</strike>


sub()

This method causes a string to be displayed as a subscript, as if it were in a <sub> tag.

Syntax

Its syntax is as follows:

string.sub ( )

Return Value

Returns the string with <sub> tag.


Example

Try the following example.

<html>

<head>

<title>JavaScript String sub() Method</title>

</head>

<body>

<script type="text/javascript">


var str = new String("Hello world");

alert(str.sub());


</script>

</body>

</html>

Output

<sub>Hello world</sub>


sup ()

This method causes a string to be displayed as a superscript, as if it were in a <sup> tag.

Syntax

Its syntax is as follows:

string.sup()

Return Value

Returns the string with <sup> tag.


Example

Try the following example.


<html>

<head>

<title>JavaScript String sup() Method</title>

</head>

<body>

<script type="text/javascript">


var str = new String("Hello world");

alert(str.sup());


</script>

</body>

</html>

Output

<sup>Hello world</sup>


0 comments:

Post a Comment