javascript - Multiply a price in a class, with the contents of another class, and a currency rate -
I have the following line formats in an HTML page that convert values from Dollars to pounds or euro.
& lt; TR & gt; & Lt; Td square = "sr-price" & gt; & Lt; Span class = "sr-price-symbol" & gt; One £ & lt; / Span & gt; & Lt; span class = "sr-price-value" & gt; 43.33 & lt; / Span & gt; & Lt; span class = "sr-price-orig" & gt; 72.85 & lt; / Span & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td square = "sr-price" & gt; & Lt; span class = "sr-price-symbol" & gt; One £ & lt; / Span & gt; & Lt; Span class = "sr-price-value" & gt; 46.99 & lt; / Span & gt; & Lt; Span class = "sr-price-orig" & gt; 79.00 & lt; / Span & gt; & Lt; / TD & gt; & Lt; / TR & gt; Using jQuery, let me use the contents of "sr-price-value" as a multiplier by using the contents of "sr-price-orig" With the second value, for example 0.59 (Dollar to pound rate).
I am currently using the following code, but the problem is that the "sr-price-value" number is used for calculation, and thus the end result is that every number The bar keeps decreasing, if the user keeps switching between pounds and euro.
$ ('sr-price-value'). Text (function (i, v) {return (v * 0.59) .tiffs (2);}); How do I calculate using the "sr-price-orig" value, so that the user can back and forth each time with no loss without price?
Instead of using v in your work Shows the old value for which you are setting text), you should use the value of .sr-price-orig . You can get it in this way:
// Get the value of the next dom element converted to the original = = original = parseflot ($ (this ) .next () .text ()); Returns (Original Value * 0.59). Tiffix (2);
Comments
Post a Comment