Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.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 手动传递此onClick事件_Javascript_Jquery - Fatal编程技术网

Javascript 手动传递此onClick事件

Javascript 手动传递此onClick事件,javascript,jquery,Javascript,Jquery,如何从其他函数手动传递“this”值 jQuery $('#divName ul li a').click(function() { $(this).addClass('active'); }); $(window).scroll(function() { //for condition a //the value of this will a //for condition b //the value of this will be });​ 选中此

如何从其他函数手动传递“this”值

jQuery

$('#divName ul li a').click(function() {
    $(this).addClass('active');
});
$(window).scroll(function() {
    //for condition a
    //the value of this will a

    //for condition b
    //the value of this will be
});​

选中此项

您是否尝试实现单击和滚动功能?将滚动处理程序放在单击处理程序中

$("div").click(function(e) {
    var target = this;
    $(window).on("scroll.clickScroll", function(e) {
        // Use "target" as the reference to what was clicked on.
    }
}
请注意,当单击停止时,必须删除处理程序,如下所示:

$(window).off("scroll.clickScroll");
我在这里使用事件名称间距来区分普通窗口滚动和专门的单击滚动

$(window).off("scroll.clickScroll");