Jquery IE 11错误:对象不';t支持属性或方法';更换';
否则,我的jquery脚本会在IE11中抛出一个错误: 错误:对象不支持属性或方法“替换” 谁能告诉我为什么 基本上,脚本只显示/隐藏div和其他内容。这取决于用于访问页面的链接是否具有特定的查询字符串 要查看错误(和代码),只需在IE11中打开以下链接。(必须打开脚本调试。) 代码Jquery IE 11错误:对象不';t支持属性或方法';更换';,jquery,internet-explorer-11,Jquery,Internet Explorer 11,否则,我的jquery脚本会在IE11中抛出一个错误: 错误:对象不支持属性或方法“替换” 谁能告诉我为什么 基本上,脚本只显示/隐藏div和其他内容。这取决于用于访问页面的链接是否具有特定的查询字符串 要查看错误(和代码),只需在IE11中打开以下链接。(必须打开脚本调试。) 代码 $(document).ready(function() { var url = window.location.href option = url.search(/[?]option=/gi); if
$(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试图在
css()
中传递的参数上使用string.replace
,而只接收一个布尔值。我看不到代码中使用的replace方法。我遗漏了什么吗?请注意,有些代码没有什么意义,例如迭代body
,只是为了检查它是否有ID?我怎么可能遗漏了?!我现在是一个快乐的露营者。谢谢阿德内奥。这只是解决提问者的问题,而不是解决问题的标题。@LeonanCarvalho。它解决了这两个问题。标题中的错误消息来自jQuery的内部代码,其中css(Boolean)
不起作用,这仅仅是因为true.replace('string','string')
无效。