📜  他的处理程序通过关键字 this 绑定到 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:00.059000             🧑  作者: Mango

代码示例1
// Preventing a link from being followed
$( "a" ).click(function( eventObject ) {
    var elem = $( this );
    if ( elem.attr( "href" ).match( /evil/ ) ) {
        eventObject.preventDefault();
        elem.addClass( "evil" );
    }
});