1、结论:在IE8中有兼容问题、会将逗号后面的空也算作一个属性,所以最后一个属性末不要加逗号
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> </body> <script src="libs/jquery-1.8.3.min.js"></script> <script type="text/javascript"> $(function(){ var data = [ { "aHref" : "javascript:;void(0)", "imgSrc": "img/swiper01.jpg", },{ "aHref" : "javascript:;void(0)", "imgSrc": "img/swiper02.jpg", },{ "aHref" : "javascript:;void(0)", "imgSrc": "img/swiper03.jpg", },{ "aHref" : "javascript:;void(0)", "imgSrc": "img/swiper04.jpg", },{ "aHref" : "javascript:;void(0)", "imgSrc": "img/swiper05.jpg", }, ]; console.log(data.length) // 1. chrome:5 // 2. firefox:5 // 3. IE:6 // 哈哈这个真的注意,建议不管数组还是对象中,最后一个元素不要加逗号 }); </script> </html>