Javascript splice string - Javascript jQuery

Javascript examples for jQuery:String

Description

Javascript splice string

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.6.4.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/* ww w . ja va2 s . co m*/
var my_array = ["apples","pears","bananas","oranges"];
var pos = $.inArray("pears", my_array);
pos !== -1 && my_array.splice(pos, 1);
$.each(my_array, function(k,v) {
    document.write(v+"<br>");
});
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials