Use javascript substring to specify character length - Javascript jQuery

Javascript examples for jQuery:String

Description

Use javascript substring to specify character length

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> 
   </head> 
   <body> 
      <script>
       $(document).ready(/*w w  w  .j  a va 2s. c  o m*/
       function (){
           var text = $("#entry-title").text();
           var x= $("#entry-title").text(text.substring(0,10));
       }
    );
   
      </script> 
      <h1 id="entry-title">This is a sample blog title</h1>  
   </body>
</html>

Related Tutorials