找回密码
 快速注册
搜索
查看: 61|回复: 2

[JS]单词首字母大写

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-4-26 23:26 |阅读模式
We can extend the String prototype
  1. String.prototype.upper=function(){return this.split(' ').map(str=>str[0].toUpperCase()+(function(x){var arr=x.split('');arr.shift();return arr.join('')})(str).toLowerCase()).join(' ')}
复制代码
and use it like this:
  1. "THE CONVERSE OF ABEL'S THEOREM ON POWER SERIES By J. E. LITTLEWOOD.".upper()
复制代码
Output:
  1. "The Converse Of Abel's Theorem On Power Series By J. E. Littlewood."
复制代码

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-9-19 03:14
HTML <input> autocapitalize attribute
  1. <input type="text" autocapitalize="words" autofocus>
复制代码

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-9-19 03:17
hbghlyj 发表于 2022-9-18 20:14
HTML &lt;input> autocapitalize attribute


没有作用啊?
Google Chrome sample
我用Chrome没有autocapitalize效果

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 15:18

Powered by Discuz!

× 快速回复 返回顶部 返回列表