我想在用戶單擊按鈕時在網頁上顯示div。使用javascript函數顯示div
有人知道如何做到這一點嗎?
我的代碼,到目前爲止,是:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso 8859-1" />
</head>
<body>
<input id="text" type="text" size="60" value="Type your text here" />
<input type="button" value="When typing whatever text display the div balise on the page" onclick="check();" />
<script type="text/javascript">
function check() {
//Display my div balise named level0;
}
</script>
</body>
</html>
感謝,
布魯諾
編輯:我所有的代碼(我已經刪除,因爲它太長,不是很清楚)
感謝您的回答。我試過了,它不起作用:我的div已經存在(命名爲level0),當我把document.body.appendchild(「level0」)沒有任何反應。 – Bruno 2011-04-14 08:26:41
div是否已經在頁面上,然後可見? – 2011-04-14 08:27:48
@Tikhon不,但沒有點擊我可以顯示它。 – Bruno 2011-04-14 08:28:35