Crop and trim string in a div - Javascript jQuery

Javascript examples for jQuery:String

Description

Crop and trim string in a div

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//  w  w w . j a  va2 s .c  o  m
$(function(){
    var el = $("div.person a");
    el.text(el.text().split('?')[0].trim());
});
    });

      </script> 
 </head> 
 <body> 
  <div class="person"> 
   <a href="#">Title ? Description</a> 
  </div>  
 </body>
</html>

Related Tutorials