双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

IE8浏览器对indexof()函数的兼容性

完美并不美cxm 完美并不美cxm 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
function showSelected(){
//在页面加载时添加被选中职员
//alert('select')
var staffs = $(".list input[type=checkbox]:gt(0)");
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++)
{
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
按照百度上面把这段代码贴在使用indexof()函数前面,还是不可以解决IE8浏览器的兼容性问题?
staffs.each(function(){
if(staffIds.indexOf(this.id)>-1){在IE8中这个地方老是提示对象不支持此属性或方法
$(this).attr('checked',true);
}else{
//alert('jj')
$(this).attr('checked',false);
}
});
if($(".list input[type=checkbox]:checked").size()==$(".list input[type=checkbox]").size()-1){
$(".selectAll").attr('checked','true');
}
}

求大神帮忙,急急急!!!!
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
完美并不美cxm
JavaScript 87,983 成员 224,681 内容