Is it possible to add a subscript tag to numbers as a user types into an textbox, for example if a user was to type in H20 it would instantly of converted to H20. I am looking for a solution using jQuery?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, textboxes may not contain html-markup. But you can replace the 2 with a subscript-2-character
₂(Unicode 2082 ).Here the function :
Call this function onkeypress.
It replaces(if a number was typed) the current selection with the subscript of that number.
Unicode-char at position 8320(HEX 2080) is subscript-zero, it just adds the typed number to that position and retrieves the char at the new position.
Demo: http://jsfiddle.net/doktormolle/KDgH9/