gaya Posted February 28, 2013 Share Posted February 28, 2013 (edited) 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 February 28, 2013 by gaya Link to comment Share on other sites More sharing options...
gaya Posted March 1, 2013 Author Share Posted March 1, 2013 (edited) <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 March 1, 2013 by gaya Link to comment Share on other sites More sharing options...
ankit bhalodiya Posted March 3, 2013 Share Posted March 3, 2013 <sub>text</sub> for subscript & <sup>text</text> for superscript Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now