Die SO-Community erwartet mindestens einen Code, mit dem Sie versucht haben, das Problem selbst zu lösen. Das ist wahrscheinlich der Grund für alle Down-Stimmen.
Aber ich werde davon ausgehen, dass JS nicht Ihre Hauptaufgabe ist und Sie nicht einmal wissen, wo ich anfangen soll, damit ich Ihnen helfen kann.
Diese Lösung benötigt keine Bibliothek, es funktioniert ohne jQuery.
// first lets get the divs by class name
var values = document.getElementsByClassName('general-avg');
// then lets go through each of the divs and select strong element inside
[].forEach.call(values, function (item) {
// assumption is that your 3rd party gives you always just one strong tag inside
var strong = item.getElementsByTagName('strong')[0];
// once we have that element selected, take the number from inside, strip $ and remove commas, parse it to float
var newValue = parseFloat(strong.innerText.replace('$','').replace(',',''));
// once we have that, multiply by 0.7 (I sure hope that is how you deduct 30%, otherwise this is emberassing)
newValue = newValue * 0.7;
// once we have that value we just need to format it a bit, this is shameless copy paste from
// http://stackoverflow.com/a/10899795/3963682
var formatNewValue = newValue.toString().split(".");
newValue = formatNewValue[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (formatNewValue[1] ? "." + formatNewValue[1] : "");
// at the end, put the number back in, and add $ sign in front
strong.innerText = '$' + newValue;
});
Beispiel: http://codepen.io/anon/pen/xgeQjV
Vielen Dank. Ich schätze es sehr. Du hast recht, JS ist nicht meine Hauptaufgabe ... meistens nur Design und einige UI-Sachen. Nochmals, danke ... das hat mir sehr geholfen. –
Miroslav, wie würde ich mit diesem auf die nächste ganze Zahl runden? Ich habe versucht, strong.innerText = '$' + Math.round (Number (newValue)); in der letzten Zeile, aber das funktioniert nicht für mich. –
Nevermind, ich habe es! :) hinzugefügt "newValue = Math.round (newValue);" gleich nach "newValue = newValue * 0.7;" –