jquery - 指定字符的自定义换行符

标签 jquery html css

我希望能够在 @ 符号之后对电子邮件进行分词。

所以它看起来像下面这样

 id | name    | email       | status
--------------------------------------
 1  | Bob joe | bjoe        | active
    |         | @gmail.com  | 
--------------------------------------
 2  | jay c   | jc@gmail.com| active
--------------------------------------
 3  | David   | dsmith      | inactive
    | Smith   | @yahoo.com  | 
                  ^ I want it to break the email right before the @sign

我目前的情况是这样的:

http://jsfiddle.net/9rjW3/

下面是相同的代码:

CSS

table{ 
    table-layout:fixed;  

    -ms-word-break: break-all; 
    word-break: break-all; 
    word-break: break-word; 

    width: 330px;
}

table td{
    overflow: hidden;
}

HTML

<table class="fixed" border="1">
    <col width="20px" />
    <col />
    <col />
    <col width="70px" />
    <tr>
        <th>#</th>
        <th>Name</th>
        <th>Email</th>
        <th>status</th>
    </tr>
    <tr>
        <td>1</td>
        <td>Kaimana Marek</td>
        <td>thisisatest@gmail.com</td>
        <td>Active</td>
    </tr>
    <tr>
        <td>2</td>
        <td>Joshua Bourguignon</td>
        <td>tasdflknadsfl@gmail.com</td>
        <td>Inactive</td>
    </tr>
    <tr>
        <td>3</td>
        <td>Ekkehard Mehmud</td>
        <td>asdflknasdc@yahoo.com</td>
        <td>Active</td>
    </tr>
</table>

是否可以使用自定义字符(如 @ 符号)对字符串进行换行?

最佳答案

类似于 s.replace(/([^\n]{10})/g, '$1\n'); 其中 {10} 是您要在其后添加分隔符的字符数。

此外,为了使其看起来一致,最好使用等宽字符,否则字符的宽度会发生很大变化。

关于jquery - 指定字符的自定义换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22971297/

相关文章:

css - IE9 : issue in a link when use filter

jquery - 喜欢在菜单上可见

jquery - 添加了 overflow-y 但现在有新的副作用

javascript - jQuery 淡入淡出效果未按预期工作

php - 在包含 PHP 变量的 HTML 字符串中转义引号的正确方法

html - 缩小 CSS 类/ID 名称?

javascript - CKEditor和JQuery验证: error message not disappearing after entering text

html - 如何根据屏幕的宽度更改页面的 CSS 样式?

css - 响应式 Bootstrap 列

javascript - 如何使用向上或向下键在动态填充的 li 元素之间导航