Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

JavaScript sup method

In the JavaScript, method sup() method is used to format text in superscript format.



JavaScript sup method


In the JavaScript, method sup() method is used to format text in superscript format. It makes a copy of that string and then embed it within <sup></sup> tags as in HTML.



It returns the copy of string in the superscript format.

Description of code:

Here we have created an input text and button. We have to supply string into the input text to convert them into superscript format. Click on the button to call the function superscriptText() as defined in the JavaScript within the <script></script> tags. It takes the text string into a variable textToSuperscript and there after we have converted the string into superscript format by calling method sup() on the string reference object. Here is the full HTML code as follows :


   Convert string to superscript
 <script language="JavaScript">
 function superscriptText()
  var textToSuperscript = document.getElementById('txt').value;
  document.write("<p> Superscript text "+
<div style="background: #ff9900; width:'100%';"
  <font color="#0000ff" size="12pt">
	<b>sup() Example</b>
  Insert any text 
 <input type="text" id="txt" /><br>
 <div id="divId" style="backgroud :#ccccff"></div>
 <input type="button" value="Convert text to superscript"
   onClick="return superscriptText();"/>


Insert any text to format them into superscript format and click on the button "Convert text to superscript" 

You can see from the following output that the text inserted "Welcome" is converted to the superscript format.

Download Source Code



Share on Google+Share on Google+

JavaScript sup method

Posted on: May 25, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: JavaScript sup method  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image