Javascript-CSS,可见性onclick
我对Javascript非常陌生。我一直在研究使用Javascript编辑css样式属性。我在网上搜索了很多不同的问题。即使有了这些,也可能是我的经验不足,无法找出代码的错误所在。增加问题的是,有很多方法可以做到这一点。不管怎么说,这里有一些细节 我希望它做什么: 当有人点击代码中的链接时,我希望隐藏的DIV(就在我等待调用的顶部附近)的可见性切换为可见,以便在页面上创建一个新层 我的代码:Javascript-CSS,可见性onclick,javascript,css,visibility,Javascript,Css,Visibility,我对Javascript非常陌生。我一直在研究使用Javascript编辑css样式属性。我在网上搜索了很多不同的问题。即使有了这些,也可能是我的经验不足,无法找出代码的错误所在。增加问题的是,有很多方法可以做到这一点。不管怎么说,这里有一些细节 我希望它做什么: 当有人点击代码中的链接时,我希望隐藏的DIV(就在我等待调用的顶部附近)的可见性切换为可见,以便在页面上创建一个新层 我的代码: <html> <head> <script lan
<html>
<head>
<script language="javascript">
function newwindow() {
var showme = document.getelementbyid("testing");
showme.style.visibility = "visible";
}
</script>
</head>
<body>
<a href="#" onclick="newwindow()">Show me my hidden layer</a>
<div id="testing" style="position: absolute; visibility: hidden; left: 50%; top: 50%;
border: 1px solid darkblue; width: 400px; height: 300px; line-height: 300px;
text-align: center; vertical-align: middle;
margin-top: -150px; margin-left: -200px; background: lightgray">HELLO!!!</div>
</body>
</html>
函数newwindow(){
var showme=document.getelementbyid(“测试”);
showme.style.visibility=“可见”;
}
你好
现在,我知道有很多方法可以做到这一点。但是,有人能告诉我,在我写这篇文章的时候,应该对代码做些什么调整吗?非常感谢您的时间。这是
document.getElementById
而不是document.getElementById
它是
document.getElementById
而不是document.getElementById
使用此代码
<html>
<head>
<script language="javascript">
function newwindow() {
var showme = document.getElementById("testing");
showme.style.visibility = "visible";
}
</script>
</head>
<body>
<a href="#" onclick="newwindow()">Show me my hidden layer</a>
<div id="testing" style="position: absolute; visibility: hidden; left: 50%; top: 50%;
border: 1px solid darkblue; width: 400px; height: 300px; line-height: 300px;
text-align: center; vertical-align: middle;
margin-top: -150px; margin-left: -200px; background: lightgray">HELLO!!!</div>
</body>
</html>
函数newwindow(){
var showme=document.getElementById(“测试”);
showme.style.visibility=“可见”;
}
你好
使用此代码
<html>
<head>
<script language="javascript">
function newwindow() {
var showme = document.getElementById("testing");
showme.style.visibility = "visible";
}
</script>
</head>
<body>
<a href="#" onclick="newwindow()">Show me my hidden layer</a>
<div id="testing" style="position: absolute; visibility: hidden; left: 50%; top: 50%;
border: 1px solid darkblue; width: 400px; height: 300px; line-height: 300px;
text-align: center; vertical-align: middle;
margin-top: -150px; margin-left: -200px; background: lightgray">HELLO!!!</div>
</body>
</html>
函数newwindow(){
var showme=document.getElementById(“测试”);
showme.style.visibility=“可见”;
}
你好
您应该使用jQuery,它是一个很棒的javascript库。您应该使用jQuery,它是一个很棒的javascript库。非常感谢各位!没有意识到Javascript是区分大小写的。没问题,很高兴我能提供帮助:)@user1935137,将此设置为正确答案如何?:)非常感谢各位!没有意识到Javascript是区分大小写的。没问题,很高兴我能提供帮助:)@user1935137,将此设置为正确答案如何?:)