How to represent fraction in a input box using jQuery I am not able to represent it the way it has to be represented! I dont want it this way , I want it in this way Right now I am using this $("[purpose=fractionadd_imp_val]").val(improper[0]+" "+imp_num+"/"+imp_den);
Asked
Active
Viewed 28 times
0

Bharadwaj
- 1
- 3
-
If you are planning to show it in input box, are you looking to even change it? – G_S Mar 11 '18 at 05:09
-
1you can't do that because 5/6 isn't a single character in any font I know of – Jaromanda X Mar 11 '18 at 05:12
-
You could use a bit of CSS to style the numbers. – Nisarg Shah Mar 11 '18 at 05:13
-
**inside** an input? @Nisarg – Jaromanda X Mar 11 '18 at 05:16
-
@JaromandaX hmm. Let's make it a contenteditable then. – Nisarg Shah Mar 11 '18 at 05:19
-
Actually the input box will be disabled ! I think What I am asking is impossible ! I should either use css or some library ! – Bharadwaj Mar 11 '18 at 05:23
-
It might be impossible if you want to edit it again. But yes if using css you can definitely achieve it. But the point is you will not be able to edit it easily – G_S Mar 11 '18 at 05:28
-
No there is no need of editing it ! – Bharadwaj Mar 11 '18 at 05:29
-
It will be a final value ! – Bharadwaj Mar 11 '18 at 05:29
-
Why not using for example Fraction.js ( https://github.com/infusion/Fraction.js ) in combination with KaTex ( https://katex.org/ ). The first parses a number and with its built-in function `Fraction(123).toTex()` you feed KaTex. Pretty good combination for what you're trying to achieve. – Robert Eisele Nov 29 '21 at 22:34