<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script> </head> <body> <div> <input type="text" id="p" /> </div> <div><button onclick="show()">haha</button></div> </body> <script> function show(){ var p=$("#p").val(); p=p.replace(/,/ig,','); var arr=p.split(","); console.log(arr); } </script> </html>