remove duplicates from string with $.unique() - Javascript jQuery

Javascript examples for jQuery:String

Description

remove duplicates from string with $.unique()

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>UL Select Box </title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from   w w  w .j av  a  2 s .  co  m*/
 $(document).ready(function(){
     data = "val1,val2,val3,val4,val5";
     arr =  $.unique(data.split(','));
     data = arr.join(",");
     console.log(data);
  });
    });

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

Related Tutorials