新知识点

toggleClass

$("button").click(function(){
$("p").toggleClass("main");
});

each中的 false

Use return false to break out of each() loops(循环) early.

$( "div" ).each(function( index, element ) {
// element == this
$( element ).css( "backgroundColor", "yellow" );
if ( $( this ).is( "#stop" ) ) {
$( "span" ).text( "Stopped at div index #" + index );
return false;
}
});
原文地址:https://www.cnblogs.com/Zara/p/6644362.html