限制 HTML 段落内的字符

发布于 2024-08-10 09:02:14 字数 92 浏览 3 评论 0原文

我想让段落内只有350个字符,无论放入多少个字符,我只想显示350个。

我该怎么做? 文本就在

文本的 div 标签中。

干杯

I want to make it so there's only 350 characters inside the paragraph, regardless of how many characters are put into it, I only want 350 displayed.

How can I do this?
The text is just in a div tag in

text.

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-黛色若梦 2024-08-17 09:02:14

您可以将文本放入文本框中,设置样式以消除它位于文本框中的事实,然后使用 size 属性限制文本框的长度。

然而,理想的解决方案是将其限制在服务器端。

You could put the text into a textbox, style away the fact that it's in a textbox and then limit the length on the textbox using the size attribute.

However, the ideal solution would be to limit it on the server side.

苄①跕圉湢 2024-08-17 09:02:14

如果您喜欢客户端解决方案,您还可以通过 JavaScript 中的 DOM 检查内容。

You can also inspect the contents via the DOM in JavaScript if you feel like a client-side solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文