为什么 javascript 在这里不起作用:http: //kodiakgroup.com/customers.html特别在 IE 7 和 8 上?Jquery 的第一个美元符号上的错误:对象不支持此属性或方法。
完整代码:
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="/css/ie.css" media="screen" />
<script src="js/json2.js"></script>
<![endif]-->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('#vertical-filters input').attr('checked', true);//Set checkboxes as checked by default
getCustomers(); //Initially call all customers
function getCustomers()
{
$('ul#customers').html('');//empty list
var definedCategoryArray=new Array();
for(var x=0; x< $('#vertical-filters li input').length; x++){
var thisItem=$('#vertical-filters li input')[x];
var thisItemName=$(thisItem).attr('id');
if ($(thisItem).is(':checked'))
definedCategoryArray[thisItemName]=true;
else
definedCategoryArray[thisItemName]=false;
}
$.getJSON('customers.json', function(data) {
for(var index in definedCategoryArray){ //cycle through categories array
console.log(index + ':' + definedCategoryArray[index]);
for(var i=0; i<data.customers.length; i++){ //cycle through json data
if (definedCategoryArray[index]==true){//if the value in the array is true (item checked)
if(data.customers[i].category == index) //match category (from definedCategoryArray index) to items in json object to parse
$('ul#customers').append('<li class="customerListItems"><a href="'+ data.customers[i].link +'"><img src="'+ data.customers[i].imageLink +'" alt="'+ data.customers[i].customerName +'" /></a></li>');
}
}
}
}).fail(function() { console.log( "error" ); });
}
//Toggle select all/deselect function
$('.selectAllBoxes').unbind('click').bind('click', function (e) {
e.preventDefault();
var checkBoxes = $('#vertical-filters input');
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
getCustomers();
});
//Check box checked function
$('#vertical-filters input').change(function(){
getCustomers();
});
});
</script>
</head>