I have this unordered list which contains some inputs, what I want to do is to type a value on the first input, like “1”, then all the other inputs, in order, gets 2, 3, 4, 5
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could do something like this, parse the first value then increment the rest based on their index:
You can give it a try here. The
if/elseconditional is checking if the value’s legit, e.g. if you hit backspace and it’s empty you won’t getNaNin every following input, inside we’ll blank out the value so it’s handled gracefully.