javascript - Fire an event only after the element is in focus -


i wish fire scroll event trigger blur() method on element in focus. present code wrote, scroll event fires when element not in focus. worried might affect performance of solution.

here present code:

$('#scroll-container').on('scroll', function() {     var focusedelement = $(".myelement:focus");     if (focusedelement.length > 0) {         focusedelement.blur();     } });  

here tried:

var focusedelement = $(".myelement:focus"); if (focusedelement.length > 0) {     $('#scroll-container').on('scroll', function() {         focusedelement.blur();     } } 

this didn't me. how scroll event trigger when element in focus , stop when element blurred?


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -