HTML5 safe usage 3
html html5
As you may recal, I wrote a small piece on #html5 input types a while go here, in which I stated:
If you use an unsupported input type in a browser it falls back to text, what I didn't knew is that reading the type with JavaScript fails also. CSS attribute selectors are fine, only no JavaScript detection.
As it turns out, I was mistaken. It is quite possible to detect the type of the input elements, all it takes is the reading of the type attribute, like this:
$('input').each(function(){
var tt = this.getAttribute('type');
if(!tt)tt='text';
this.className +=' input-'+tt;
});
And voila, we have got a class on the element, with which we can style it or hook some javascript onto it...