<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<script src="lib/jquery/jquery-1.3.2.js">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery2.1</title>
<script>
function showjQueryObjectMethod(){
var value = $("body *:hidden");
alert($("body *:hidden").length);
}
</script>
</head>
<body>
<input type="hidden" name="ids">
<div id="hasH1" style="display:none">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="hasH2">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="nohasH1">
</div>
<input type="button" name="button" id="button" value="普通的username名称" onclick="showjQueryObjectMethod()"/>
</body>
</html>
--------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<script src="lib/jquery/jquery-1.3.2.js">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery2.1</title>
<script>
function showjQueryObjectMethod(){
var value = $("body *:visible");
alert($("body *:visible").length);
}
</script>
</head>
<body>
<input type="hidden" name="ids">
<div id="hasH1" style="display:none">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="hasH2">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="nohasH1">
</div>
<input type="button" name="button" id="button" value="普通的username名称" onclick="showjQueryObjectMethod()"/>
</body>
</html>
----------------------------------请教啊,,,这个div标签id是nohashH1的到底是隐藏啊,还是显示啊,怎么二段 代码都有它呢?我用firebug调试都有这个,请教一下
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<script src="lib/jquery/jquery-1.3.2.js">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery2.1</title>
<script>
function showjQueryObjectMethod(){
var value = $("body *:hidden");
alert($("body *:hidden").length);
}
</script>
</head>
<body>
<input type="hidden" name="ids">
<div id="hasH1" style="display:none">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="hasH2">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="nohasH1">
</div>
<input type="button" name="button" id="button" value="普通的username名称" onclick="showjQueryObjectMethod()"/>
</body>
</html>
--------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<script src="lib/jquery/jquery-1.3.2.js">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery2.1</title>
<script>
function showjQueryObjectMethod(){
var value = $("body *:visible");
alert($("body *:visible").length);
}
</script>
</head>
<body>
<input type="hidden" name="ids">
<div id="hasH1" style="display:none">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="hasH2">
<h1></h1>
<h1>h2</h1>
<h1>h2h2</h1>
</div>
<div id="nohasH1">
</div>
<input type="button" name="button" id="button" value="普通的username名称" onclick="showjQueryObjectMethod()"/>
</body>
</html>
----------------------------------请教啊,,,这个div标签id是nohashH1的到底是隐藏啊,还是显示啊,怎么二段 代码都有它呢?我用firebug调试都有这个,请教一下
//:hidden定义
Sizzle.selectors.filters.hidden = function(elem){
return elem.offsetWidth === 0 || elem.offsetHeight === 0;
};
//:visible定义
Sizzle.selectors.filters.visible = function(elem){
return elem.offsetWidth > 0 || elem.offsetHeight > 0;
};
但为什么隐藏和显示都有nohashH1啊》那它的offsetWidth offsetHeight 到底是什么值啊?
<div id="nohasH1"></div> 当中没有内容
offsetHeight === 0;
offsetWidth !== 0;
所以:hidden和:visible都返回true
<div id="nohasH1"> </div> 当中没有内容
offsetHeight === 0;
offsetWidth !== 0;
所以:hidden和:visible都返回true
---------您刚才讲的我没有看懂啊,,,,<div id="nohasH1"> </div>中的offsetHeight offsetWidth 值是多少
offsetWidth = 根据父元素大小
LZ不是用firebug的吗 可以看的
return elem.offsetWidth > 0 || elem.offsetHeight > 0;
};
不应该被匹配啊,,,
elem.offsetHeight > 0 // false
// true