Lägg till text efter räknaren i javascript.

Permalänk

Lägg till text efter räknaren i javascript.

Jag vill lägga till text som en enhet efter att kalkylatorn har beräknat siffrorna. Texten som ska visas efter räknaren är en "%" och "st" hur lägger jag in det i koden? Använder Purecounterjs.

<script src="https://cdn.jsdelivr.net/npm/@srexi/purecounterjs/dist/pureco..."></script>
<script>
new PureCounter({
// Setting that can't' be overriden on pre-element
selector: '.tips', // HTML query selector for spesific element

// Settings that can be overridden on per-element basis, by `data-purecounter-*` attributes:
start: 190000, // Starting number [unit]
end: 200000, // End number [unit]
duration: 6, // The time in seconds for the animation to complete [seconds]
delay: 10, // The delay between each iteration (the default of 10 will produce 100 fps) [miliseconds]
once: true, // Counting at once or recount when the element in view [boolean]
repeat: false, // Repeat count for certain time [boolean:false|seconds]
decimals: 0, // How many decimal places to show. [unit]
legacy: true, // If this is true it will use the scroll event listener on browsers
filesizing: false, // This will enable/disable File Size format [boolean]
currency: false, // This will enable/disable Currency format. Use it for set the symbol too [boolean|char|string]
separator: false, // This will enable/disable comma separator for thousands. Use it for set the symbol too [boolean|char|string]
});
new PureCounter({
// Setting that can't' be overriden on pre-element
selector: '.tips3', // HTML query selector for spesific element

// Settings that can be overridden on per-element basis, by `data-purecounter-*` attributes:
start: 0, // Starting number [unit]
end: 30, // End number [unit]
duration: 1, // The time in seconds for the animation to complete [seconds]
delay: 10, // The delay between each iteration (the default of 10 will produce 100 fps) [miliseconds]
once: true, // Counting at once or recount when the element in view [boolean]
repeat: false, // Repeat count for certain time [boolean:false|seconds]
decimals: 0, // How many decimal places to show. [unit]
legacy: true, // If this is true it will use the scroll event listener on browsers
filesizing: false, // This will enable/disable File Size format [boolean]
currency: false, // This will enable/disable Currency format. Use it for set the symbol too [boolean|char|string]
separator: false, // This will enable/disable comma separator for thousands. Use it for set the symbol too[boolean|char|string]
});

</script>

Jag vet inte hur jag ska lägga in det i koden. Har försökt sätta in den vid "start" och lägga till [%] efter startvärdet. Men det fungerar inte. Testade även med ["%"] samma sak gäller med [st] testade även med ["st"].

Permalänk
Medlem

Eftersom scriptet du nyttjar är minifierat hade jag skippat helt att försöka analysera det och göra ändringar i det.
Jag tolkar det som att svaret din calculator skapar hamnar i .tips3.
Skapa en eventlistener på change där och lägg till % eller vad du nu vill där.