How do I change the counter value?
-
Good day, tell me how you can change the counter value when there is only access to adding custom CSS and JS in the store.
Two values need to be changed separately 58/400
Let's add 20 to 58
Where 400 take away 200
JavaScript Hazel Robertson, Nov 13, 2019 -
// Найти уникальный селектор для искомого элемента
var elem = document.querySelector('div.xserver__status');
// спарсить значения
let [a, b] = elem.innerText.split(/\D*\/\D*/).map(Number);
// вернуть новые
elem.innerText = `${a + 20} / ${b - 200}`;Caroline Singh -
var text = document.querySelector('.xserver__status').innerText;
var arr = text.split(' / ');
arr[0] = parseInt(arr[0]) + 20;
arr[1] = parseInt(arr[1]) - 200;
document.querySelector('.xserver__status').innerText = arr.join(' / ');Harrison Burgess
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!