Ry-*_*Ry- 5

它使用this$$作为上下文,即返回的所有元素必须是它的后代.默认是document.


Den*_*nis 5

$('.pblabel', this).text(newVal + '%');
Run Code Online (Sandbox Code Playgroud)

是一样的

$(this).find('.pblabel').text(newVal + '%');
Run Code Online (Sandbox Code Playgroud)

实际上,这就是它在内部重写和运行的方式.它被称为"上下文选择器".

来自jQuery源码:

// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
    return ( context || rootjQuery ).find( selector );

// HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr)
} else {
    return this.constructor( context ).find( selector );
}
Run Code Online (Sandbox Code Playgroud)