Fixed error with jquery (version 1.7.2) type property can't be changed.
Apparently attr also wants to change the element. Using !== to check equality now