当我尝试使用 javascript/jquery 将某些文本替换为其他某些文本时出现此错误。
这里是错误:
Uncaught TypeError: Object [object HTMLAnchorElement] has no method 'html'
这是网站上的 javascript 行:
$(document).ready({
var navigationLinks = $('.nav a');
for(var i=0; i < navigationLinks.length; i++){
var thisLink = navigationLinks[i];
switch(thisLink.html()){
case "About":
thisLink.html().replace(/About/g,'');
case "Work":
thisLink.html().replace(/Work/g,'');
case "CV":
thisLink.html().replace(/CV/g,'');
case "Resume":
thisLink.html().replace(/Resume/g,'');
case "down":
thisLink.html().replace(/down/g,'');
case "Mail":
thisLink.html().replace(/Mail/g,'');
case "Dribbble":
thisLink.html().replace(/Dribbble/g,'');
case "GooglePlus":
thisLink.html().replace(/GooglePlus/g,'');
case "Facebook":
thisLink.html().replace(/Facebook/g,'');
case "Twitter":
thisLink.html().replace(/Twitter/g,'');
default:
thisLink.html().replace(thisLink.html(),thisLink.html());
}
}
window.onscroll=scrollFunc;
});
最佳答案
改变:
navigationLinks[i]; // DOM element which doesn't have an `html` function
收件人:
navigationLinks.eq(i);// jQuery wrapper which does have an `html` function
关于javascript - 未捕获的类型错误说函数不能应用于对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15937619/