Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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
jQuery添加事件_Jquery_Css - Fatal编程技术网

jQuery添加事件

jQuery添加事件,jquery,css,Jquery,Css,以下jQuery代码通过调用函数scroll\u position jQuery.event.add(window, "scroll", scroll_position); function scroll_position() { var p = jQuery(window).scrollTop(); jQuery(scrollbox).css('position',((p+10)>start) ? 'fixed' : 'absolute');

以下jQuery代码通过调用函数
scroll\u position

jQuery.event.add(window, "scroll", scroll_position);

function scroll_position() {
        var p = jQuery(window).scrollTop();
        jQuery(scrollbox).css('position',((p+10)>start) ? 'fixed' : 'absolute');
        jQuery(scrollbox).css('top',((p+10)>start) ? '10px' : '');
    }

是否可以在不使用功能scroll_position的情况下添加此事件?我的意思是,我只想做同样的事情,不使用函数。(我没有任何理由不使用这个函数,只是学习jQuery)。

当你不想用它做任何事情时,你需要一个事件做什么

您可以执行内联函数,例如

jQuery.event.add(window, "scroll", function() {
    alert("magic happens here");
});

这样你就不需要自己的功能了……

当你不想做任何事情的时候,你需要一个活动做什么

您可以执行内联函数,例如

jQuery.event.add(window, "scroll", function() {
    alert("magic happens here");
});

这样,您就不需要自己的函数了……

只需绑定事件挂起.bind或.live,然后在需要使用.trigger时触发它


不需要jQuery.event.add

只需绑定挂起的事件.bind或.live,然后在需要使用.trigger时触发它


不需要jQuery.event.add

不使用函数是什么意思?您想触发什么事件?不使用函数是什么意思?你想触发什么事件?哦,这就是我的意思,内联函数。谢谢。哦,这就是我的意思,内联函数。谢谢