我想要将一个单词截断为50个字符,但在50个字符中,它不应该是一个HTML标签.假设我有以下的HTML:
<p>This is a test message</p>This is a test message<p>This is a test <a href="#">message</a> </p>
然后它应该计算50个字符,只包括"这是一条测试消息这是一条测试消息"
截断后,它应该显示如下:
<p>This is a test message</p>This is a test message<p>This</p>
我希望使用jQuery来实现这一点.
100: 抱歉,再加一个条件:
我想显示到最后一个点,但不能超过50个字符,如下所示:
<p>This is a test message</p>This is a test message.<p>This is a test <a href="#">message.</a> </p>
则输出将为
<p>This is a test message</p>This is a test message.