Changing the value of the first letter of each word

后端 未结 6 1109
我寻月下人不归
我寻月下人不归 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:38

    Ajma solution works if you have only one h1 in your page.

    This works for all h1 :

      $('h1').each(function() {
         var jqt = $(this);
         var txt = jqt.text();
         jqt.html(''+txt.substring(0,1)+''+ txt.substring(1));
      });
    

    Possible improvements : instead of a span with a style, create a span with a class and do font-size:200% in CSS.

    Possible problems : if your h1 contains other tags (which it should not!) those tags are lost, only text is retained.

    Hope it helps, Simone

提交回复
热议问题