Prevent "Syntax error, unrecognized expression: :nth-child"

When current index is 'undefined', use 0 and don't send 'NaN' to jQuery.