Jump to content

Subsctipt and superscript


gaya

Recommended Posts

Hi,I want to do the button for subscript and superscript. For example now, when we r typing the question in this textarea, if we want to highlight the main text we r selecting the statement and we click the B for bold. Then our statement becomes like <b>.....</b> Like this i want to do for subscript and superscript. If i give X2 I want to do like X<sub>2</sub>. Please tell me how to do this.

Edited by gaya
Link to comment
Share on other sites

<button type="button" onclick="addtext();getfocus();">Subscript</button>function addtext() {var newtext = document.getElementById("ques1").value;newtext += prompt("enter the value",'<sub></sub>');document.getElementById("ques1").value = newtext;document.getElementById('ques1').focus();}

The above is my code. I did it for one textarea. But if i'm having another textarea and i want to include the subscript in that textarea only, How can i do this.Please tell me.

Edited by gaya
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...