0
I have the following elements :
<span class="teste">256,00</span>
<span class="teste">110,00</span>
<span class="teste">16,00</span>
<span class="teste">26,00</span>
I would like to know a way to modify each value by traversing the span and adding an extra percentage in each value. this as jQuery code. Can anyone help me with this ? These are just examples.
Thank you !
I cannot create multiple spans ids, the span class is one for all products. Example, I would like to give a discount of 10 real in all spans with this class... wanted a function that did this, but I do not know how to do.
– Wesley Igor
You need for everyone or just a randomly chosen value?
– Gabriel Rodrigues
I don’t think you understand, friend... imagine this, I have a product sales website. Each product has its price, the price of the products vary, but are placed in the same span class. What I want to do is take the value that is in the span class (i.e., the value of the product), and give a percentage discount. ie if it is with value of 256,00 the value will change to 230,40. if I give 10% discount.
– Wesley Igor
I edited the answer, I think it is this, just go through the elements with each and perform the calculation of each item, an improvement in your question with these details that Voce reported here, why there I understood something randomly, until why Voce used this word, if you had said go through the span elements and update the value of each one would have been much more effective this response.
– Gabriel Rodrigues
Thank you very much friend, it worked, but I found a problem, because when the value is in thousand, a problem occurs.
– Wesley Igor
Friend another doubt already taking advantage of your good will rsrs, if in case came R$ in front of each value, how could I calculate ?
– Wesley Igor
Come on, the focus of the answer is exactly how Voce can change the value of spans as title, but I’m going to indicate a path to follow, you need to remove the money mask before you do the calculation, have several plugins and codes for this, after you do the calculation back to mask, as to put R$ in the amount all right, as long as you remember to remove it to calculate...
– Gabriel Rodrigues
Could you help me with this code that removes the mask for the calculation ?
– Wesley Igor
http://blog.fmansano.com/javascript/converter-numero-para-moeda-e-versa/ this article explains how...
– Gabriel Rodrigues