How can I limit a text string with javascript or jquery???
I have a data brought from the database, but that data is too long and it undoes my design, what I want is, for example, if that data is greater than a certain number of characters with javascript or jquery put "..." substituting to the rest of the paragraph, how can I do that?
Thanks in advance :)
you can do something like this:
Try this:
You must be careful because if the length (number of characters to display) is greater than the text, an undefined will appear. This would be fixed as follows:
It is a solution similar to the previous ones, but perhaps it is somewhat shorter than the second, and more elaborate than the first:
Now, when it's time to collect the data, inside the loop that I assume you'll create to iterate through that data, just always pass that same data through this filter: (example)
I hope it helps.