小编Dav*_*vid的帖子

为什么indexOf在Internet Explorer中不起作用?

此函数在表单onSubmit期间执行,并且在Firefox和Chrome中正常工作,但在IE中则不行.我怀疑它是indexOf,但我似乎找不到让它工作的方法.

function checkSuburbMatch(e) {

var theSuburb = document.getElementById('suburb').value;
var thePostcode = document.getElementById('postcode').value;

var arrayNeedle = theSuburb + " (" + thePostcode + ")";

if(suburbs.indexOf(arrayNeedle) != -1) {
    alert("Suburb and Postcode match!");
    return false;
} else {
    alert("Suburb and Postcode do not match!");
    return false;
}

}
Run Code Online (Sandbox Code Playgroud)

javascript internet-explorer indexof

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

indexof ×1

internet-explorer ×1

javascript ×1