Category Archives: String

Find Number of Characters in string No ratings yet.

We can find the number of characters in a string using the length property of JQuery as follows:  

  Likes(0)Dislikes(0) Please rate this Sample rating item

Trim string using javascript No ratings yet.

You can do this using various techniques. Some of them are as follows: Method 1: Using Plain Javascript: You can do it using the simple simple Javascript expression as follows:

Output:

  Method two: Using trim() function of Jquery: In order to trim a string, firstly you can use the $.trim() function of Jquery to make the input string… Read More »

Truncate string to nearest white space using Javascript No ratings yet.

Method One: Set the length. So that after the 10th character, if any space appears the string will get truncated.

Output:

  Method two:

Output:

  Method three: Using regular expresion

Output:

  Likes(0)Dislikes(0) Please rate this Sample rating item