gpt4 book ai didi

javascript - 在 JavaScript 中更改分隔线的显示属性

转载 作者:可可西里 更新时间:2023-11-01 13:24:54 26 4
gpt4 key购买 nike

我正在用 HTML(当然还有 CSS 和 JS)开发这个程序,但是我在一些代码上遇到了问题,因为我想让一个区域可以管理,这样你就可以让它可见,或者在你想要的时候不可见.如果你不明白我的意思,我就用代码告诉你。

//browserSearching.js
// First, the variables!
var link = document.getElementById("searchbar").value;
var page = document.getElementsByTagName("iframe").src;

var button = {
menu: document.getElementById("dropdown"),
enter: document.getElementById("enter"),
back: document.getElementById("back"),
forward: document.getElementById("forward")
}

var more = document.getElementById("more");

// Now it is time for functions!

function enableMore() {
if (more.style.display == "block") {
more.style.display == "none"
} else {
more.style.display == "block"
}
}

function update() {
link = document.getElementById("searchbar").value;

setTimeout(update, 1);
}
// style.css
#splitter {
margin-bottom: 0px;
}

// This part is not really needed
<!--Indext.html-->
<!DOCTYPE html>
<html>
<head>
<title>Web Browser in Web Browser</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="data.js"></script>
</head>
<body style="margin: 0px;" onload="update();">
<browser>
<div id="top">

<!-- First Layer -->
<div id="tabs">
<tab></tab>
</div>
<br /><!-- Second Layer --> <hr />
&#160;
<button id="back">&#60;</button>
<button id="forward">&#62;</button>
<button id="home">H</button>

<input id="searchbar" style="width: 1107px;" />
<button id="enter" onclick="page = link;">Ent</button>

<button id="dropdown" onclick="enableMore();"> : </button>

<div id="more" style="display: none;">

<!-- This is all one button, and it was hard! -->
<label for="themes" class="button">Upload CSS Theme</label>
<input id="themes" style="display: none;" type="file" />
<!-- End of the button -->
</div>
</div>
<hr id="splitter"/>
<iframe name="webpage" src="browser.html" width="1277.5px" height="640px" style="border-width: 0px;"></iframe>
</browser>
<script src="browserSearching.js"></script>
</body>
</html>

你明白我想说的了吗?只需按下 [:] 按钮...按下时不会显示任何内容

最佳答案

在您的 enableMore() 函数中,您在进行比较时需要进行赋值。

== 更改为 =,如下所示:

function enableMore() {
if (more.style.display == "block") {
more.style.display = "none" // Double-equals changed to single
} else {
more.style.display = "block" // Double-equals changed to single
}
}

Working Codepen

关于javascript - 在 JavaScript 中更改分隔线的显示属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40336659/

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