Not working two script together?

Have two script next:

$(window).scroll(function(e){
parallax();
});
function parallax(){
 var scrolled = $(window).scrollTop();
$('#lk-conteyner').css('background-position-y',+(scrolled*0.5)+'px');
}




$(window).scroll(function(e){
parallax();
});
function parallax(){
 var scrolled = $(window).scrollTop();
 $('.Robort_svg svg').css('top',-(scrolled*0.2)+'px');
}


Both create a parallax effect
Works, for some reason, only the second

What's the problem, how to fix?
Thank you!
June 14th 19 at 20:16
2 answers
June 14th 19 at 20:18
Solution
your option is not a gentleman: at each scroll event on the window will bind a new event handler.
$(window).scroll(parallax);
var lkContainer = $('#lk-conteyner');
var robotSVG = $('.Robort_svg svg');
function parallax() {
 var scrolled = $(window).scrollTop();
lkContainer.css('background-position-y',+(scrolled*0.5)+'px');
robotSVG.css('top',-(scrolled*0.2)+'px');
}


learn the theory, otherwise you'll have formulait until the end of time.
wow, Spasibo )) - estefania32 commented on June 14th 19 at 20:21
June 14th 19 at 20:20
Solution
Ugh

Combined them and earned:

$(window).scroll(function(e){
parallax();
});
function parallax(){
 var scrolled = $(window).scrollTop();
$('#lk-conteyner').css('background-position-y',+(scrolled*0.5)+'px');

$(window).scroll(function(e){
parallax();
});
function parallax(){
 var scrolled = $(window).scrollTop();
 $('.Robort_svg svg').css('top',-(scrolled*0.2)+'px');
}}


I do not know how this gentleman, but it works =)

Find more questions by tags JavaScriptjQuery