Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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_Scroll_Click - Fatal编程技术网

jquery滚动并在同一功能中单击

jquery滚动并在同一功能中单击,jquery,scroll,click,Jquery,Scroll,Click,我希望有人能在这里帮助我。我有这个jquery脚本,它是在这个站点上实现的。www.runebs.dk(代码为Rune) $(窗口).trigger('scroll');//初始化值 }); $(窗口).on('scroll',function(){ var pos=$(“#副标题”).offset(); $('.article header')。每个(函数(){ 如果(pos.top>=$(this).offset().top&&pos.top抱歉,无法理解您到底想要什么。与您的问题无关,但

我希望有人能在这里帮助我。我有这个jquery脚本,它是在这个站点上实现的。www.runebs.dk(代码为Rune)

$(窗口).trigger('scroll');//初始化值
}); 
$(窗口).on('scroll',function(){
var pos=$(“#副标题”).offset();
$('.article header')。每个(函数(){

如果(pos.top>=$(this).offset().top&&pos.top抱歉,无法理解您到底想要什么。与您的问题无关,但您应该将
$('button')移动。单击(…)
滚动事件处理程序外部。否则,将为滚动的每个触发器绑定单击事件(可能会很多)一次点击就会触发多个点击。我试图移动$('button')。点击(…)外部,但当我这样做时,点击功能不再工作。但我确信解决方案接近于此。你会怎么做?像这样?我如何再次添加代码?谢谢你的例子。不幸的是,当我尝试滑动切换不工作时。有什么想法吗?如果在e第一函数?
    $(window).trigger('scroll'); // init the value
}); 

$(window).on('scroll', function(){
    var pos = $('#subHeadline').offset();
    $('.article-header').each(function() {
        if (pos.top >= $(this).offset().top && pos.top <= $(this).next().offset().top) {
            $('#subHeadline').html($(this).html());
            return;
        }
    });

    $('button').on('click', function () {
        $(this).text($(this).text() == '(-)' ? '(+)' : '(-)');
        $('.description' ).slideToggle('fast');
    });
});
$(window).on("scroll", function(){
//implement the functionality for the scroll
}).find("#buttonID").on("click", function(){
//write functionality for the button
});