split string with Javascript - Javascript jQuery

Javascript examples for jQuery:String

Description

split string with Javascript

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://code.jquery.com/jquery-1.4.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from www.j a v  a 2 s.c o m
$('#smallcart .plusone').live('click',function(){
   var id = $(this).attr('id');
   articlenr = id.split('_')[1];
    console.log(articlenr);
});
    });

      </script> 
 </head> 
 <body> 
  <div id="smallcart"> 
   <span id="test_1" class="plusone">Click me!</span> 
  </div>  
 </body>
</html>

Related Tutorials