开发者

jquery event - getting the context

开发者 https://www.devze.com 2022-12-13 05:11 出处:网络
if I have : $(\'.someClass\', $(\'#context1,#context1\')).bind(\'click\', function(e){ /开发者_如何学编程/ XXX

if I have :

$('.someClass', $('#context1,#context1')).bind('click',
    function(e){
    /开发者_如何学编程/ XXX
    }
);

how can I know in point XXX , which context (context1 or context2) is the one that the .someClass element was clicked ?

Thanks, greetings


This should work

$(this).parents().filter("#context1,#context2")

Edit: My previous example had find instead of filter, I've fixed it

0

精彩评论

暂无评论...
验证码 换一张
取 消