ID generator playing badly with jQuery in corner case