如何将一个输入的第一个字母大写? [英] How can I capitalize the first letter of an input?
本文介绍了如何将一个输入的第一个字母大写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我尝试的:
字段集输入
{
text-transform:capitalize;
}
但它不能按我想要的方式工作, 。
我也尝试过:
letter
{
text-transform:uppercase;
}
但看起来< input /根本不用第一个字母...
无论如何,你有没有想过如何实现这个没有javascript(或尽可能少)?
解决方案
JS : str.charAt(0).toUpperCase ;
I'm currently trying to capitalize the very first letter from an input.
Here's what I tryed :
fieldset input
{
text-transform:capitalize;
}
But it doesn't work the way I want, as every word is capitalized.
I also tryed this :
fieldset input:first-letter
{
text-transform:uppercase;
}
But it seems <input /> doesn't work at all with first-letter...
Anyway, do you have any idea of how to achieve this without javascript (or as little as possible) ?
解决方案
JS: str.charAt(0).toUpperCase();
这篇关于如何将一个输入的第一个字母大写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文