简体   繁体   English

JavaScript,将div中的前200个字符换行

[英]javascript, wrap first 200 characters in a div

im making an accordion for a client. 我正在为客户制作手风琴。 there website is built on .net, something of which i have no idea how it works. 那里的网站是建立在.net上的,我不知道它是如何工作的。

my current accordion is something similar too... 我现在的手风琴也很类似...

<h1>Header</h1>
<span class="content">Content here</span>

I need something more like 我需要更多类似的东西

<h1>Header</h1>
<span class="entry-content">summary  here</span>
<span class="content">Content here</span>

I want the 'entry-content' to show initially and when the h1 is clicked the 'content' div slides down. 我希望最初显示“ entry-content”,然后单击h1时,“ content” div会向下滑动。

As its in .net all the content is pulled from the following line... 由于其在.net中,所有内容均从以下行中提取...

<%#Eval("Information")%>

is there a way with JS i can wrap the first 200 characters in a div, and the rest can be wrapped in another div? JS有没有办法将div中的前200个字符包装起来,而其余的可以包装在另一个div中呢?

I hope this makes sense! 我希望这是有道理的!

我认为这可以解决问题, http://jsfiddle.net/UX3sC/

Answer to the section javascript, wrap first 200 characters in a div 回答部分javascript,将前200个字符包装在div中

Dion Jones: you are already doing that with Circadians code, it will give you the HTML markup: 迪翁·琼斯(Dion Jones):您已经使用Circadians代码进行了此操作,它将为您提供HTML标记:

<h1>Header</h1>
<span class="entry-content">summary  here</span>
<span class="content">Content here</span>

Or you want the markup to look any other way? 还是您希望标记以其他方式显示?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM