Solution for not triggering document events in iPhone safari [Bubble]

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.