0 votes
1 view
in Java by (9.2k points)

Can anyone tell me a JS listener to be used when a user scrolls in a certain textbox with cross-browser compatibility?

1 Answer

0 votes
by (19k points)

Below is the JQuery code to add scroll listening to a number of CSS-selector elements:

// what should we do when scrolling occurs

var runOnScroll =  function(evt) {

  // not the most exciting thing, but a thing nonetheless

  console.log(evt.target);

};

// grab elements as array, rather than as NodeList

var elements = document.querySelectorAll("...");

elements = Array.prototype.slice.call(elements);

// and then make each element do something on scroll

elements.forEach(function(element) {

  window.addEventListener("scroll", runOnScroll, {passive: true});

});

Interested in Java? Check out this Java Certification by Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked May 9 in Java by sheela_singh (9.2k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...