This is a div element
<div>
<label>some text 1</label>
<label>another text 1</label>
</div>
<button>button</button>
Each time the button is clicked, a new div tag will be added. The digit in the label text of each new div should increment.
For example: The first div should have 1
, the second div should have 2
, and so on.
I am currently retrieving the label text using
var labelValue = $('div').find('label').map(function() {
return $(this).text().replace(/\d/,2);
}).get();
My goal is to update the digit in the label text to 2.
Although I can fetch the value, the label text in the HTML remains unchanged.
How can I display the updated label value?
Apologies for any errors in my code.