选择链接此关键字的插件之外的元素

select elements outsde of plugin chaining this keyword

本文关键字:元素 插件 选择 关键字 链接      更新时间:2023-09-26

我正在创建一个链接插件,问题是我想选择THIS元素之外的元素,例如

return $this.each(function() {
    $('body $left .filter-wrapper input[type=checkbox]', document).change(function() {
        alert('changed');// I want to break out side the scope how do i do that
        and select element that aren't in $('mygrid').Grid()
        // ive tried $('body $left .filter-wrapper input[type=checkbox]') 
        // that doesn't work either
    }).find(this).filter(....).click(function() {
        // this refers to mygrid which is what i want but the ubove code doen't work 
    }).find(....).click(function(){
        // do more stuff here
    }).bind('....')
});

$ (' mygrid ') .Grid ()

请检查你的问题格式,它很难阅读。

如果你想选择$(this)之外的元素,你可以考虑像平常那样选择它们:

$("div.clickable").click(function() {
    $(this).hide();
    $("div.outsidethis").doSomething();
});

或者,您可以使用$.proxy()将当前上下文传递给方法:

$("div.clickable").click($.proxy(function(){
    // this is now NOT div.clickable but whatever this was before
}, this));
http://api.jquery.com/jQuery.proxy/