JavaScript Reference/Javascript Methods/substr

Материал из Web эксперт
Перейти к: навигация, поиск

"substr()" Example

   <source lang="javascript">
   

<html> <body> <button onclick="var myS = new String("Sample String");

                alert(myS.substr(4,7));">

sub string</button> </body> </html>


     </source>
   
  


"substr()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |String | +----------------+--------------------------------------------------------------+

     </source>
   
  


"substr()" Syntax Parameters and Note

   <source lang="javascript">

Note: Get string"s sub string.

Syntax:

stringName.substr(param1, param2) Parameters:

   param1   Required; the character number.
   param2   Required; the length of the subset string. 
   
     
     </source>