試圖刪除我的網站上的一些文本使用jQuery頁面加載完成後,代碼無法正常工作。在Chrome瀏覽器中查看JS控制檯時,出現以下錯誤Uncaught TypeError: Cannot read property 'replace' of undefined
。Javascript/Jquery uncaught typeerror試圖替換html
這裏是我的替換文本代碼:
<script>
window.onload = function(){
var replaced = $("footer-copy").html().replace("'s Frontpage",'');
$("footer-copy").html(replaced);
};
</script>
我試圖更新HTML:
<div class="footer-wrap">
<div class="footer-copy">© 2017 <a href="https://blog.andrewgottschling.me/">Andrew Gottschling's Frontpage</a> Powered by <a href="https://leafpub.org" target="_blank">Leafpub</a></div>
<div class="footer-design-author"><span>Design with</span> <i class="i-favorite heart"></i> by <a href="https://leafpub.org" target="_blank" title="Desarrollador Web FullStack.">@leafpub</a></div>
</div>
感謝提前所有幫助。 :d
謝謝。不知道我是如何錯過的。 – agottschling