Changing the value of the first letter of each word

后端 未结 6 1108
我寻月下人不归
我寻月下人不归 2020-12-06 18:14

I\'m attempting to either use jQuery, CSS or PHP to increase the font size of the first letter of each word in a string. For example, I\'m going to have a title in h1 tags

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 18:21

    This will work. Just set in your CSS to h1 span {font-size: 125%}, or whatever.

    $('h1').each(function(){
        var $this = $(this);
        var words = $this.text().split(' ');
        var newHtml = '';
        for (var i = 0; i < words.length; i++) {
             newHtml += '' + words[i].substring(0, 1) + '' + words[i].substring(1) + ' ';
        }
        $this.html(newHtml);
    });
    

提交回复
热议问题