How does bootstrap's datepicker detect that datepicker is turned off when a user clicks on another area of the page

  1. begins to think that input will bind blur events, but the user"s click time control is also a blur event that triggers input , which is not feasible
  2. .
  3. guess that it may be a click event bound to document . At this time, check whether event.target contains class of bootstrap , but think that datepicker should not have a fixed class for every element.
  4. The
  5. guess will use the containes method, such as binding the click event of document to determine whether the currently clicked event is in the top class of datapicker .
  6. set up a mask layer on the page, the background is transparent, and the z-index value is smaller than datepicker . When you click on other areas of the page, you click on the mask layer, and then the time control is hidden. But the user does not know that this is clicking on the transparent layer, and when clicking on other operable areas, the user will find that the click does not respond (because it is hiding the time control and hiding the transparent layer operation), and on the second click, the transparent layer has been removed before you can click on other actions. So this scheme will also have disadvantages

would you like to ask if there is any better way

Feb.28,2021
Menu