我對JavaScript很新穎。我一直在尋找使用JavaScript來編輯CSS樣式屬性。我搜索了網頁,看了很多不同的問題。即使有了這些,也許我沒有經驗,爲什麼我無法弄清楚我的代碼出了什麼問題。問題增加的原因是有很多方法可以做到這一點。無論如何,這裏是具體細節。Javascript - CSS,知名度onclick
我想要它做什麼: 當有人點擊代碼的鏈接,我想隱藏的DIV(這將只是靠近我等待的頂部上被稱爲)有其知名度切換爲了在頁面上創建一個新圖層。
我的代碼:
<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>
現在,我知道有很多的方法可以做到這一點。但是有人可以告訴我在我編寫這個工作的代碼中調整什麼?非常感謝您的時間。
你應該使用jQuery,這是一個夢幻般的JavaScript庫。 http://jquery.com/ –
JavaScript區分大小寫。 –