【发布时间】:2013-02-23 21:28:23
【问题描述】:
IE8 好像不支持 Jquery .filter() 方法 - Why won't .filter() work in Internet Explorer 8?
我有以下过滤下拉列表的代码
if($('#deliveryPostcodeEstimator').length > 0) {
$('.shippingregionselector').hide();
$('#deliveryPostcodeEstimator')
.blur(function() {
//Set to default
$('select[name=country] option:last').prop('selected', true);
//var defaultPostcode = 'GL50';
//$("select[name=country] option").filter(function() {
// return $(this).text() == defaultPostcode;
//}).prop('selected', true);
//Set to matching postcode value if set
$('select[name=country] option').filter(function(index) {
return ($(this).text() == $('#deliveryPostcodeEstimator').val().toUpperCase().substring(0,4).trim())
}).prop('selected', true);
//Submit
var thisForm = $(this).closest("form");
thisForm.submit();
})
.keyup(function() {
$(this).val($(this).val().toUpperCase());
});
$('button.pcodechange').click(function() {
var thisForm = $(this).closest("form");
thisForm.submit();
});
}
问题线是
return ($(this).text() == $('#deliveryPostcodeEstimator').val().toUpperCase().substring(0,4).trim())
这给出了以下错误
Object doesn't support this property or method
如何按照上一篇文章中的建议“将其包装在一个对象中”?
谢谢
【问题讨论】:
-
jQuery.filter 和 array.filter 是不同的东西
-
It looks like IE8 doesn't support the Jquery .filter() method您是否在浏览器调试工具的控制台中收到错误或任何警告消息?您是否也在 Chromer/FireFox 中运行过它?您是否尝试过创建fiddle 来检查它是否在那里工作? -
好的。所以也许我的问题应该更像是“我怎样才能让它在 IE8 中工作?”在 Chrome/FF 中没问题
-
错误是“对象不支持这个属性或方法”
-
你用的是什么版本的jQuery?
标签: jquery arrays internet-explorer-8 filter