I want to fire a function when my focus is out with tab key of a div `#search` no matter what is around it. I can't figure out how to do it. At the moment my `console.log()` fires when I focus out of my inputs in my `#search` div.

```js
$("#search").focusout(function () {
   if ($(this).has(document.activeElement).length == 0) {
       console.log('OUT'); // need to fire when i'm on Link2 or button: "random" (with tab key, not only click)
   }
});
```

```css
*:focus {
  outline: 4px solid red;
}

#search {
  margin: 30px 0;
}
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="#">Link1</a>
<a href="#">Link2</a>

<div id="search">
  <input type="text">
  <button>Search</button>
</div>

<button>Random</button>
```