admin管理员组文章数量:1316833
var txt = 'Some texts, html tags & all values i can enter through text box';
txt= txt.substring(0,255)+'...';
Can i do this thing using css?
My problem is if txt
contains HTML tags, after doing a sub string the closing tag gets missing and it will break.
var txt = 'Some texts, html tags & all values i can enter through text box';
txt= txt.substring(0,255)+'...';
Can i do this thing using css?
My problem is if txt
contains HTML tags, after doing a sub string the closing tag gets missing and it will break.
- Why are u doing a substring(). What is the expected result? – Akhil Sekharan Commented Jul 25, 2013 at 5:52
- Please explain the issue you are having. – andrewb Commented Jul 25, 2013 at 5:53
-
2
You can use CSS ->
text-overflow:ellipsis;
– adeneo Commented Jul 25, 2013 at 5:53 - Can you give an example in "jsfiddle" – Ishan Jain Commented Jul 25, 2013 at 6:10
- 1 thnk you every one for helping – Reshma Commented Jul 26, 2013 at 7:28
3 Answers
Reset to default 5But for this you should set width
of element -
Try this CSS -
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 100%;
display: inline-block;
See in jsfiddle
CSS will only work when you have to display the txt information on screen in some elements such as <div>
or <p>
In order to make text appear with ellipses, try the following CSS properties
p{
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
If you're using jQuery, you can use it's text()
function.
var txt = 'Some texts, html tags & all values i can enter through text box';
txt= txt.text().substring(0,255)+'...';
That will display all non-html elements.
本文标签: javascriptsubstring a text with html tags using css break word or somethingStack Overflow
版权声明:本文标题:javascript - substring a text with html tags using css break word or something? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742013975a2413420.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论