This is because your using an onClick event within your markup to register a click event through jQuery. In other words, your toggleEdit function is only executed when you click an item, this then attaches click events to the rest of the items and waits for the next click.
onClick() events and mixing Javascript amongst your markup are a thing of the past since jQuery and other frameworks now allow you to easily attach events to code without them.
This concept should be covered in any 'beginner' jQuery tutorials. It really is one of the fundamentals of the framework.