Q:

How to get substring from a string using jQuery

0

How to get substring from a string using jQuery

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the JavaScript substring() method

You can easily extract a substring out of a string using the JavaScript substring() method. The substring() method return substring based on the start (required) and end-position (optional) arguments. If end position is not specified it extracts the rest of the string.

Let's take a look at the following example to understand how this method basically works:

<script>
$(document).ready(function(){
    var myStr = "The quick brown fox jumps over the lazy dog";
    var subStr = myStr.substring(4, 20);
    alert(subStr);
});
</script>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

JavaScript / jQuery Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Show read more link if the text exceeds a certain ... >>
<< How to find mouse position relative to an element ...