skip to Main Content

I am rewriting a jquery function and I would like to know how to write the jquery focusout function in vanilla?

var inputBox = $('.searchbox-input');
// ...
inputBox.focusout();

2

Answers


  1. document.getElementsByClassName('searchbox-input').onfocusout = function(){ ... };
    
    Login or Signup to reply.
  2. You can use dispatchEvent as a (near) equivalent to jQuery’s trigger.

    document.querySelector('.searchbox-input').dispatchEvent(new Event('focusout'));
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search