开发者

get the innerhtml inside a div

The html code is pasted into this url http://jsfiddle.net/nzYjV/

The div (id="input") contains the string of alphabet.. Between the "input" div and "d1" div, there are 34 character (including space). Inside the "d1" div, there are 16 character (including space) Finally, between ending of "d1" div and before end tag of "input" tag, there is 9 character (including space).

I have to show limited number of string and add link for viewing whole content e.g.

1)suppose string limit is 30,the output would be

a b c d e f g h i j k l m n o ... [a href="#"]view more[/a]

and output html would be

[div id="input"]a b c d e f g h i j k l m n o [/div]

2)But, if the string limit is 40, then the output would be

a b c d e f g h i j k l m n o p q r s t...  [a href="#"]view more[/a]

And the output html would be

[div id="input"]a b c d e f g h i j k l m n o p q [div id="d1"] r s t [/div][/div]

3) And, if the string limit is 55, then the output would be

a b c d e f g h i j k l m n o p q r s t u v q x y z a1 b1开发者_高级运维...  [a href="#"]view more[/a]

And the output html would be

[div id="input"]a b c d e f g h i j k l m n o p q [div id="d1"] r s tb u v w x y[/div]z a1 b1[/div]

i am able to get the inner text of "input" div and "d1" div. But, i am not able to get the last text "z a1 b1 c1", if the 3rd condition is true.

Sorry for bad editing.. Please help me to solve this


Solved... using this js file https://github.com/tagedieb/jquery-truncate

Another set of truncate..

https://github.com/Poetro/jQuery-Truncate

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜