joehungjohn
joehungjohn

Reputation: 71

How to implement jquery-throttle-debounce on addEventListener

I don't know what I'm doing so I'm trying to just "copy what I see without knowing what I'm doing"...

<script>

// This works:

$window.scroll($.throttle(50, function(event) {
  // stuff happens
}));

// These don't work

target.addEventListener($.throttle(50,"mouseover", function(event) {

}, false));

I also tried

target.addEventListener.throttle("mouseover", function(event) {
  // do stuff
}, false), 50);

</script>

As if it was a setTimeout

Can someone help.

Upvotes: 0

Views: 363

Answers (1)

Abcd
Abcd

Reputation: 79

$('button').on('click', $.throttle(100,function() {
    // ...
}));

$('button').click($.throttle(100,function() {
    // ...
}));

Upvotes: 1

Related Questions