Vertical Text with jQuery

后端 未结 6 1835
猫巷女王i
猫巷女王i 2021-02-15 14:11

I\'m looking to vertically align text by adding
tags between characters with jQuery.

6条回答
  •  花落未央
    2021-02-15 15:12

    Mr Kurt's answer works well for a single id, but if you want something more useful that can be applied to several elements try something like this:

    $.each( $(".verticalText"), function () { $(this).html($(this).text().replace(/(.)/g, "$1
    ")) } );

    Then just set class="verticalText" on the elements you want to be formatted like this.

    And as a bonus it keeps the boob regex.

提交回复
热议问题