javascript - walk throught each li child input find value and increase by one other -


gurus! have list of li's

<ul>  <li><input type="hidden" value="7" name="order"></li>  <li><input type="hidden" value="3" name="order"></li>  <li><input type="hidden" value="6" name="order"></li>  <li><input type="hidden" value="5" name="order"></li>  <li><input type="hidden" value="1" name="order"></li>  <li><input type="hidden" value="2" name="order"></li> </ul> 

i want add new li hidden input list , set value of input val+1 - increase 1 finding maximum values of inputs.

can me?

please favour , use jquery this:

var total;  $('li').find('input').each(function(){     total = total == undefined || parseint($(this).val()) > total ? parseint($(this).val()) : total;  })  $('ul').append('<li><input type="hidden" value="' + (total + 1) + '" name="order"></li>'); 

the total variable populated sum of input values. can use in whatever way you'd like.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -