`valuenow = valuenow === parseInt( $elm.attr( "max" ), 10 ) ? 0 : valuenow + 1;` and then `valuemax` can be removed