gpt4 book ai didi

jquery - IE 11错误: Object doesn't support property or method 'replace'

转载 作者:行者123 更新时间:2023-12-01 01:32:20 25 4
gpt4 key购买 nike

我的 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 尝试对 css() 中传递的参数使用 string.replace 而只是接收一个 bool 值。

关于jquery - IE 11错误: Object doesn't support property or method 'replace' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35323979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com