Skip to content

Instantly share code, notes, and snippets.

@ricardobeat
Created December 22, 2010 20:14
Show Gist options
  • Save ricardobeat/752033 to your computer and use it in GitHub Desktop.
Save ricardobeat/752033 to your computer and use it in GitHub Desktop.
Adds classes to input elements in Internet Explorer according to it's type
// ================================================
// workaround para seletor de atributos type (ex: [type=text]) no IE6
// cria classe type_valorDoAtributo
// repetir no CSS (não pode estar no mesmo seletor):
// input[type=text] { x:y; }
// input.type_text { x:y; }
// -
(function(){
if (! ($.browser.msie && $.browser.version < 7) )
return false;
var inputs = document.getElementsByTagName('input')
, ln = inputs.length
, input
, type;
while(ln--){
input = inputs[ln];
type = (input.getAttribute ? input.getAttribute('type') : input.type) || "text";
input.className = (input.className + ' type_' + type).replace(/^\s+/, '');
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment