Java Coder
How to substring in JQuery?
1 Answer(s)      4 years and a month ago
Posted in : HTML


I my JQuery application I am getting the value from server using Ajax. I have to substring the value in jQuery.

There is a variable in my program as follows:

var technologyName = "Language JavaScript";

I just want to take the value JavaScript from the above variable. Please let's know How to substring in JQuery?



View Answers

January 21, 2013 at 11:24 AM


There is no need to use the jQuery for getting the smaller from a big string.

JavaScript provides convenient function for this purpose.

Here is the description of the substring function of JavaScript:

string.substring(start, to);

from: value is required and it specifies the index from where program will start the extraction.

to: this is option value. If no value is specified all the string will extracted till end of the string.

Here is the complete example html and javascript code:

  <title>JQuery Substring</title>
  <script lanuage="JavaScript">
    function test(){
        var technologyName = "Language JavaScript";
        alert("Technology:" + technologyName);
        technologyName = technologyName.substring(9);
        alert("Technology:" + technologyName);

  <a href="javascript:test()">Substring</a>