Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery slideToggle()回调函数_Javascript_Jquery_Callback_Slidetoggle - Fatal编程技术网

Javascript jQuery slideToggle()回调函数

Javascript jQuery slideToggle()回调函数,javascript,jquery,callback,slidetoggle,Javascript,Jquery,Callback,Slidetoggle,以下是jQuery slideToggle函数: $('.class').click(function() { $(this).parent().next().slideToggle('slow', function() { // how can I access $('.class') that was clicked on // $(this) returns the $(this).parent().next() which is the eleme

以下是jQuery slideToggle函数:

$('.class').click(function() {
    $(this).parent().next().slideToggle('slow', function() {
        // how can I access $('.class') that was clicked on
        // $(this) returns the $(this).parent().next() which is the element
        // that is currently being toggled/slided
    });
});

在回调函数中,我需要访问current.class元素(被单击的元素)。我该怎么做呢?

在回调函数外部引用元素,然后在回调函数内部使用它

$('.class').click(function() {
    var $el = $(this);
    $(this).parent().next().slideToggle('slow', function() {
         //use $el here
    });
});
谢谢:)我没想到这么简单的解决办法。