gpt4 book ai didi

javascript - 为什么一个功能可以工作,而另一个却不能?

转载 作者:行者123 更新时间:2023-11-28 03:22:47 25 4
gpt4 key购买 nike

这个有效,它显示了表格:当我输入 .style.display = "tablerow"时,该函数起作用

var getMain = document.getElementById("main").style.display = "table-row";
var getLocalStorage = localStorage.hasOwnProperty('tableFill');
for (i = 0; i < getLocalStorage.lenght; i++) {
if (getLocalStorage[i]){


getMain;

但是当我将它放入 for 循环中时,它不再起作用,但我在控制台中也没有收到任何错误......

var getMain = document.getElementById("main");
var getLocalStorage = localStorage.hasOwnProperty('tableFill');
for (i = 0; i < getLocalStorage.lenght; i++) {
if (getLocalStorage[i]){


getMain.style.display = "table-row";

最佳答案

localStorage.hasOwnProperty('tableFill') 返回 true 或 false。没有任何长度,因此您不会进入循环。

关于javascript - 为什么一个功能可以工作,而另一个却不能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58973112/

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