它也一样
影响
把他们都藏起来,但内部却不完全一样,不。
.each()
接受一个回调,其中
this
可以用来做特定的事情
每个
元素,所以它可以做更多的工作。
.hide()
在一个链子里
display: none;
在元素上(存储它们以前的值)。
You can see how it works internally here
,对于没有参数的呼叫:
for ( var i = 0, l = this.length; i < l; i++ ) {
var old = jQuery.data(this[i], "olddisplay");
if ( !old && old !== "none" ) {
jQuery.data( this[i], "olddisplay", jQuery.css( this[i], "display" ) );
}
}
// Set the display of the elements in a second loop
// to avoid the constant reflow
for ( var j = 0, k = this.length; j < k; j++ ) {
this[j].style.display = "none";
}
在上面
这
引用元素集
$('.class_el_1, .class_el_2')
匹配,只使用
for
循环阅读。