简体   繁体   中英

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.

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.

As its in .net all the content is pulled from the following line...

<%#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?

I hope this makes sense!

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

Answer to the section javascript, wrap first 200 characters in a div

Dion Jones: you are already doing that with Circadians code, it will give you the HTML markup:

<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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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