Skip to content

Instantly share code, notes, and snippets.

View pfiaux's full-sized avatar

Patrick Fiaux pfiaux

View GitHub Profile
@pfiaux
pfiaux / changeTypeAttr.js
Created September 20, 2012 11:19 — forked from bminer/changeTypeAttr.js
Cross-browser solution to change the 'type' attribute of an `<input/>` tag. Edited to work in Drupal.
/* id is the id tag of <input/> element
type is the type you want to change it to.
jQuery is required and assumed to be the jQuery variable */
function changeType(id, type) {
var x = jQuery("#"+id);
if(x.attr('type') == type)
return x; //That was easy.
try {
return x.attr('type', type); //Stupid IE security will not allow this
} catch(e) {