<分区>
有什么方法可以在失去焦点时在输入文本上设置 background-color
吗?
我正在 js 中尝试,但我想知道在纯 css 中是否可行。
这似乎不起作用
input{
background-color:#fff !important;
}
input:focus{
background-color:#333 !important;
}
//input:unfocused and has value{ ??? :) }
$('input,textarea').on('focusout',function(e){
if($(this).val().length){
$(this).css('background-color','#fff');
}
});
谢谢