How can I target input fields of type \'text\' using CSS selectors?
You can use :text Selector to select all inputs with type text
Working Fiddle
$(document).ready(function () {
$(":text").css({ //or $("input:text")
'background': 'green',
'color':'#fff'
});
});
:text is a jQuery extension and not part of the CSS specification, queries using :text cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use [type="text"] instead. This will work for IE6+.
$("[type=text]").css({ // or $("input[type=text]")
'background': 'green',
'color':'#fff'
});
CSS
[type=text] // or input[type=text]
{
background: green;
}