Ich versuche diese funktion zu bekommen - aber es geht nicht das geht das $ (this) wenn es gefeuert wird. Ich fand diese Frage, was scheint, wirklich ähnliche Frage zu sein (How to use $(this) in functions?), aber ich kann nicht herausfinden, warum es in meinem Fall nicht funktioniert.
Es wäre toll, wenn mir jemand helfen könnte. Dank
function scrolll(){
var thiss = $(this).attr('id').substring(1);
var pos = $(this).scrollTop();
// var next = Number(thiss) + 1;
// var prev = Number(thiss) - 1;
count = Number(thiss);
if (pos == 0) {
$(".section#s" + (count - 1)).removeClass("inactive", 1500, "linear");
$(this).removeClass("active", 1500, "linear");
var count = Number(thiss) - 1;
}
if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
$(this).addClass("inactive", 1500, "linear");
$(".section#s" + (count + 1)).addClass("active", 1500, "linear");
var count = Number(thiss) + 1;
console.log("countbefore: " + count);
count++;
console.log("countafter: " + count);
}
}
$('.section1').on('scroll', function() {
console.log(thiss)
scrolll($(this));
});
$('.section2').on('scroll', function() {
console.log(thiss)
scrolll($(this));
});
vielen Dank, das war genau das, was ich gesucht habe. - Und es funktioniert. –