返回到:Prototype – 元素对象
此方法返回一个布尔值,指示元素是否可见,即其内联样式属性是否设置为“display: none;”。
注– 不考虑通过 CSS 样式表应用的样式。请注意,这不是原型限制,而是 CSS 限制。
语法
element.visible();
返回值
一个 HTML 元素。
例子
HTML
x
36
36
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
if( $('visible').visible() ) {
9
alert("$('visible').visible() returns true" );
10
} else {
11
alert("$('visible').visible() returns false" );
12
}
13
14
if( $('hidden').visible() ) {
15
alert("$('hidden').visible() returns true" );
16
} else {
17
alert("$('hidden').visible() returns false" );
18
}
19
}
20
</script>
21
</head>
22
23
<body>
24
<p>Click button to see the result</p>
25
26
<div id = "visible" style = "display:block;">
27
This is visible division
28
</div>
29
30
<div id = "hidden" style = "display: none;">
31
This is hidden division
32
</div>
33
34
<input type = "button" value = "Click" onclick = "showResult();"/>
35
</body>
36
</html>
返回到:Prototype – 元素对象
阅读剩余 83%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8971.html