5
I wish I could change the pennies of li by input of MudarCentavos. But not setando Id us li and get treated Idfor Id, because this list will be dynamic, so can come more than 3 values.
Note: 2 decimal places
function MudarCentavos() {
var getCentavos = document.getElementById('getCentavos').value
console.log(getCentavos)
}
<label>Mudar centavos</label>
<input type="text" maxlength="2" pattern="([0-9]|[0-9]|[0-9])" id="getCentavos">
<button onclick="MudarCentavos()">Submit</button>
<ul>
<li>24.50</li>
<li>10.2</li>
<li>43</li>
</ul>
Example
If I put in input 99 and give the Submit, the output of the values shall be:
24.99
10.99
43.99
Thank you!
Can you be more specific? In 'change the cents of the p', where has p? when changing you want to zero all the cents and go adding the new ones? wants to replace only by input ?
– Felipe Duarte
@Felipe Mistaken the tag, is the
li. has notp... I will update the question with an example of how you would like it =)– Jackson