HTML DOM visibility ÊôÐÔ
¶¨ÒåºÍÓ÷¨
visibility ÊôÐÔÉèÖÃÔªËØÊÇ·ñ¿É¼û¡£
Óï·¨£º
Object.style.visibility=visible|hidden|collapse
¿ÉÄܵÄÖµ
Öµ | ÃèÊö |
---|---|
visible | ĬÈÏ¡£ÔªËØ¿òÊǿɼûµÄ¡£ |
hidden | ÔªËØ¿ò²»¿É¼û£¬µ«ÈÔȻӰÏì²¼¾Ö¡£ |
collapse | µ±ÔÚ±í¸ñÔªËØÖÐʹÓÃʱ£¬´ËÖµ¿Éɾ³ýÒ»ÐлòÒ»ÁУ¬µ«ÊÇËü²»»áÓ°Ïì±í¸ñµÄ²¼¾Ö¡£±»ÐлòÁÐÕ¼¾ÝµÄ¿Õ¼ä»áÁô¸øÆäËûÄÚÈÝʹÓá£Èç¹û´ËÖµ±»ÓÃÔÚÆäËûµÄÔªËØÉÏ£¬»á³ÊÏÖΪ "hidden"¡£ |
ʵÀý
ÏÂÃæµÄÀý×ÓÒþ²ØÒ»¶ÎÎı¾£º
<html>
<head>
<script type="text/javascript">
function changeVisibility()
{
document.getElementById("p1").style.visibility="hidden";
}
</script>
</head>
<body>
<p id="p1">This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>
<form>
<input type="button" onclick="changeVisibility()"
value="Hide paragraph" />
</form>
</body>
</html>