javascript cut string if too long
if (string.length > 25) {
string = string.substring(0, 24) + "...";
}
//or
function truncate(str, n){
return (str.length > n) ? str.substr(0, n-1) + '…' : str;
};
//or with CSS
p {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
//or with replace
short = long.replace(/(.{7})..+/, "$1…");
Also in JavaScript:
- angular navigate using component
- expresiones ternarias javascript
- no styles are appearing in angular calendar
- javascript call() & apply() vs bind()?
- how to register key presses in p5.js
- javascript function to format phone number
- hadoop master node storage configuration
- nexusjs file upload
- create nodejs new object
- prevent default on enter press
- how to stop the node server from running
- javascript detect when scrolling to bottom
- retore react app
- mongoose delete property
- Did you mean "@babel/transform-react-jsx-source"
- how to prevent previous radio button active react native
- jquery slidetoggle
- forEach modify array JavaScript
- how to add seconds to time in js
- javascript round to 2 decimal places
- simple alert program in javascript
- how to add a class in classlist and remove after 100 ms using jquery
- text number of lines react native
- vue truncate text