简体   繁体   English

用javascript / jquery更改单词字体大小的首字母

[英]change First letter of word font size with javascript/jquery

Is there a way to select the first letter of each word with either javascript or jQuery? 有没有办法用javascript或jQuery选择每个单词的首字母?

Im trying to make tags on my page have the first letter of each word be a bigger font size. 我正在尝试使页面上的标签的每个单词的第一个字母的字体更大。 Im assuming it involves regular expressions but all i keep finding are things for form validation. 我假设它涉及正则表达式,但我一直发现的只是用于表单验证的东西。 I also see a bunch of stuff for capitalizing the first word. 我还看到了很多大写第一个单词的东西。 I'm trying to change the font size. 我正在尝试更改字体大小。

Does anyone know if this can be done and how? 有谁知道这是否可以做到以及如何做到? Thanks. 谢谢。

If you are just looking for a styling change, you might be able to get away with pure CSS using :first-letter . 如果只想更改样式,则可以使用:first-letter摆脱纯CSS 的困扰

Here's an example: http://jsfiddle.net/bgNP3/1/ 这是一个示例: http : //jsfiddle.net/bgNP3/1/

Note: I apparently had to make the span s into inline-block s for the effect to work. 注意:为了使效果正常工作,我显然必须将span变成inline-block

Update fixed link to jsfiddle. 更新固定链接到jsfiddle。

You could try using: 您可以尝试使用:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM