I have like 120 img in HTML, that are loaded properly with Javascript when click event occurs.
Then i get the attribute "src" from the img and store it in var currentModalImg_src
.
For example, i receive the image number 10, and i have this string :
var currentModalImg_src = "img/reclamos-sinaleticas/Full/f(10).jpg";
Then i extract only the number and store it in this variable: var imgSrcNumber
Then i decrement that value by 1 and replace the string with that value.
But with this code:
currentModalImg_src = currentModalImg_src.replace( /\d/g, imgSrcNumber-1);
Im getting this (it's replacing the two digits):
img/reclamos-sinaleticas/Full/f(99).jpg
The result i want is this :
`var currentModalImg_src = "img/reclamos-sinaleticas/Full/f(9).jpg";
For numbers like 8 or 23 (examples) works fine, the problem is when it's 10 or 100 for example.
Is there an efficient way solve this? Thanks for your attenttion.