I have a span where the value possibilities are: "Showing 1 item" or "Showing x to y of z items". Z can be any positive number.
<div class="result-container">
<span id="results-label">Showing 1 to 10 of 33 items</span>
</div>
I would like to be able to identify z and place it into a newly created span above this, using jQuery. Please note that "item(s)" is not static due to translations. Desired output:
<div class="result-container">
<span id="total-results">33</span>
<span id="results-label">Showing 1 to 10 of 33 items</span>
</div>
The regex I am using is \d+(?=[A-Za-z\s]*$) which seems to work https://rubular.com/r/KrHmLUzEsWGU3P
I have two issues:
- For some reason creating and inserting a new span fails:
https://jsfiddle.net/ubte7jx3/
- I am unsure how to insert the regex result into the span afterwards.