判断数组里面是否包含某个元素可以使用 $.inArray("元素(字符串)",数组名称) 进行判断 ,当存在该元素(字符串)时,返回该元素在数组的下标,不存在时返回 -1

示例代码:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <title> Jquery判断数组中是否包含某个元素$.inArray()的用法 </title>
 5     <script src="../Js/jquery-1.9.1.min.js" type="text/javascript"></script>
 6     <script type="text/javascript">
 7         $(function () {
 8             var array = ["asp.net", "asp.net mvc", "html5", "css3", "jquery", "JavaScript"];
 9             var index = $.inArray("asp.net mvc", array);   //结果:index=1
10             if (index >= 0) {
11                 console.log("数组array包含asp.net mvc下标为:" + index);
12             } else {
13                 console.log("数组array 不包含asp.net mvc下标为:" + index);
14             }
15         });
16     </script>
17 </head>
18 <body>
19 </body>
20 </html>