Reputation: 6797
What I want is to increment a value on the trigger
by scroll by 0.1
using jQuery.
pval = 0
$(window).on('scroll', function() {
pval++
pval = 0.+pval
console.log(pval);
});
I know it's a wrong way but I tried many ways but it's not happening anyway.Can you guys help me with this?
Upvotes: 0
Views: 666
Reputation: 122008
Correct syntax is pval = 0.1 +pval
or you can shorten with +=
var pval = 0;
$(window).on('scroll', function() {
pval += 0.1; //short for pval = pval+ 0.1
console.log(pval);
});
Upvotes: 2