Write a drop-down menu and hide it when you click a blank area.
The first time is to use $ (document). Click (function () {// hide code });
All browsers are fine, but the events on the iPhone are not triggered.
Later, I checked the cause and found that in Safari, the event was handled in the following way:
1. Click a div or other element.
2. If the event is not handled, continue to bubble up.
3. If no one handles the event until the child node under the body is bubbling, the event will be discarded. Do not bubble up.
4. As long as a node in this bubble chain processes the event, it will not discard the event, and will continue to run upwards. It will pop up to the body and then document and then window.
If the problem is discovered, one person must handle the event before it can continue to run.
The solution is to write an empty function at the lower level of the body to receive the event. That's all.
$ ("Body"). Children (). Click (function (){
// Do not write any code here
});
Perfect solution!
Solution for not triggering document events in iPhone safari [Bubble]