EDITABLE CODE:
LiveDemo:jQuery - Reading Attributes using attr() and each() Method
Note:If you need to reinsert an element you can do it with detach()