gpt4 book ai didi

Jquery 无法在 IE 7,8 上运行

转载 作者:行者123 更新时间:2023-12-01 07:18:31 25 4
gpt4 key购买 nike

为什么 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>

最佳答案

jQuery 2.0 已放弃对 IE 版本 6、7 和 8 的支持,并且将无法工作。来自发行说明:

No more support for IE 6/7/8: Remember that this can also affect IE9 and even IE10 if they are used in their “Compatibility View” modes that emulate older versions. To prevent these newer IE versions from slipping back into prehistoric modes, we suggest you always use an X-UA-Compatible tag or HTTP header. If you can use the HTTP header it is slightly better for performance because it avoids a potential browser parser restart.

来源:jQuery 2.0 Released

您可以尝试使用 1.9。

关于Jquery 无法在 IE 7,8 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16451554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com