我的jquery脚本(否则可以正常工作)在IE11中引发错误:
错误:对象不支持属性或方法“替换”
谁能告诉我为什么?
基本上,脚本仅显示/隐藏div和其他内容。它基于用于访问页面的链接是否具有特定的查询字符串来执行此操作。
要查看错误(和代码),只需在IE11中打开以下链接。(必须打开脚本调试。)
https://jsfiddle.net/rpt613/dp2kcL7v/
代码...
$(document).ready(function() {
var url = window.location.href
option = url.search(/[?]option=/gi);
if (option != -1) {
showContent();
changeStyle();
removeShowLink();
} else {
$('div.backToTaskList, div.spacer, div.backLink').css('display' ==
'none');
}
});
function showContent() {
$('.backToTaskList, div.spacer').hide();
$('span.toggleTaskList').hide();
$('#RelatedTopics').hide();
}
function removeShowLink() {
$("body").each(function() {
if ($(this).prop("id") == 'allTask') {
$('div.backToTaskList:contains("Show More")').each(
function() {
$(this).html($(this).html().split(
"Show More").join(""));
$("span#pipe").remove();
});
}
});
}
/* Restyle h2 to match styling of h1*/
function changeStyle() {
$("h2.programmingtask").css({
"color": "#199bd8",
"font-weight": "normal",
"font-style": "normal",
"font-size": "14pt",
"font-family": "Verdana",
"margin-top": "45px"
});
/* Replace text content of h2 element with its ID attribute*/
var replaceWith = $("h2.programmingtask, h1.programmingtask").attr('id');
$("h2.programmingtask, h1.programmingtask").text(replaceWith);
}
是这条线
$('div.backToTaskList, div.spacer, div.backLink').css('display' == 'none');
它应该是
$('div.backToTaskList, div.spacer, div.backLink').css('display', 'none');
这在任何浏览器中都是一个错误,因为jQuery尝试使用string.replace
传入的参数css()
,而只接收一个布尔值。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句