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
Post a Comment