sách gpt4 ai đã đi

Ẩn một div bằng JS (đơn giản)

In lại 作者:行者123 更新时间:2023-12-03 10:47:07 29 4
mua khóa gpt4 Nike

嗨,所以我需要做的是最终让 regStart 和 regPage 根据点击事件交替可见性,我不太担心编写 JavaScript 函数,但我根本无法让我的 regPage 首先隐藏。这是我的代码。请简单回答,我是 JS 新手。



`enter code here`
<đầu>
SuperSite





SuperSite




Already a registered SuperSite user? Sign in with one of the following services.



facebook
google
Windows Live
Yahoo!


  • sign in with your SuperSite username and password

  • add another authentication service from the list above

  • change your SuperSite password



If you haven't already registered with SuperSite


Register Now



Register to use SuperSite services with the following form:


UserName:



Password:



Verify Password:







1 Câu trả lời

您在以下行有错误:

document.getElementByID// ID, D is in uppercase

应该是:

document.getElementById //Id, d is in lowercase

由于您使用可见性,即使 div 隐藏,该空间也会被 div 占据。

您可以使用样式的显示属性来删除这些空白。

CSS

#regStart{display:block;}
#regPage{display:none;}

或与JavaScript

function setVisibility() {
document.getElementById('regStart').style.display = 'block';
document.getElementById('regPage').style.display = 'none';
}

关于javascript - 使用JS隐藏div(简单),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28533524/

29 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com