By default, div cannot obtain focus and cannot trigger focus and blur events. It is assumed that span, a and other tags cannot trigger focus events (input:button, and button tags can trigger)
How to Make the div trigger the blur event: You can add the tabindex attribute to the div
Online demonstration: http://sandbox.runjs.cn/show/e0bvfcag
Source code:
<meta charset="UTF-8"> <title>Document</title> <style> .box{ width: 200px; height: 200px; background-color: #3295F2; } </style> <script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/294/c4c2o6mh/jquery.js"></script> <input type="text"> <input type="button" value="测试" class="but"> <button>kkk</button> <div class="box" tabindex="1"></div> <script> $('.box').focus(function(){ alert('div focus'); }); $('.box').blur(function(){ alert('div blur'); }); $('.but').focus(function(){ alert('but'); }); $('.but').blur(function(){ alert('but'); }); $('button').focus(function(){ alert('but'); }); $('button').blur(function(){ alert('but'); }); </script>
demo: http://www .w3school.com.cn/tiy/t.asp?f=html_standard_tabindex

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...

What are the disadvantages of using native select on your phone? When developing applications on mobile devices, it is very important to choose the right UI components. Many developers...

Use Three.js and Octree to optimize collision handling of third-person roaming in the room. Use Octree in Three.js to implement third-person roaming in the room and add collisions...

Issues with native select on mobile phones When developing applications on mobile devices, we often encounter scenarios where users need to make choices. Although native sel...

Exploring the implementation principle of mouse scrolling events When browsing some websites, you may notice that some page elements still allow scrolling the entire page when the mouse is hovering...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment
