R Reveley R Reveley - 29 days ago 16
jQuery Question

jQuery select multiple types of text based inputs

I'm using a jQuery hack to fix a bug in Chrome that causes alignment problems in empty fields. Chrome align-items: baseline for select and input elements

$('input:text').each(function(i,el) {
if (!el.value || el.value == '') {
el.placeholder = ' ';
}
});


I want to affect all text style inputs (text,email,date,tel,number etc) without affecting radios checkboxes and range sliders as it seems a neater way to do it.

Is there a way to do this without listing each input type individually?

Answer

Remove type=checkbox and type=radio

$('input:not([type='radio']:not([type='checkbox']))')
Comments