获取div内的innerhtml
html代码粘贴到这个url http://jsfiddle.net/nzYjV/
div (id="输入”)包含字母表字符串.. 在“input”div和“d1”div之间有34个字符(包括空格)。 “d1”div内有16个字符(包括空格) 最后,在“d1”div 的结尾和“input”标签的结束标签之前,有 9 个字符(包括空格)。
我必须显示有限数量的字符串并添加用于查看整个内容的链接,例如
1)假设字符串限制为 30,则输出为
a b c d e f g h i j k l m n o ... [a href="#"]view more[/a]
,输出 html 为
[div id="input"]a b c d e f g h i j k l m n o [/div]
2)但是,如果字符串限制为 40,则输出将为
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输出html将是
[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)并且,如果字符串限制是55,那么输出将是
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]
并且输出html将是
[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]
我能够获取“input”div和“d1”div的内部文本。但是,如果第三个条件为真,我无法获取最后一个文本“z a1 b1 c1”。
抱歉编辑不好。请帮我解决这个问题
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了...使用这个js文件
https://github.com/tagedieb/jquery-truncate
另一组截断..
https://github.com/Poetro/jQuery-Truncate
Solved... using this js file
https://github.com/tagedieb/jquery-truncate
Another set of truncate..
https://github.com/Poetro/jQuery-Truncate