javascript – How to substring in jquery

javascript – How to substring in jquery

No jQuery needed! Just use the substring method:

var gorge = name.substring(4);

Or if the text you want to remove isnt static:

var name = nameGorge;
var toRemove = name;
var gorge = name.replace(toRemove,);

Using .split(). (Second version uses .slice() and .join() on the Array.)

var result = name.split(name)[1];
var result = name.split(name).slice( 1 ).join(); // May be a little safer

Using .replace().

var result = name.replace(name,);

Using .slice() on a String.

var result = name.slice( 4 );

javascript – How to substring in jquery

Standard javascript will do that using the following syntax:

string.substring(from, to)

var name = nameGorge;
var output = name.substring(4);

Read more here: http://www.w3schools.com/jsref/jsref_substring.asp

Leave a Reply

Your email address will not be published. Required fields are marked *