"Go" Issues with on click events failing in iOS

Source: Internet
Author: User

This is about using

$ (document). On (' click ', selector,function)

Workaround for invalid use of On Click event in Mobile iOS

1. Add selector elements to the style Cursor:pointer

<style>   . a{   width:100px;  height:100px; background:red;}. b{  width:10px height:10px;cursor:pointer}</style><div class= "A" >     <div class= "B" ></ Div></div><script>   $ (document). On (' click ', '. B ', function () {console.log (' 22222 ')}) </script >

  

2. Change the Click to Touchstart (Basic on the mobile side)

1 <script>2    $ (document). On ("Touchstart",function() {console.log (' 22222 ') )})3 </script>

3. Replace the document with the parent element of the selector element

<script>   $ (". a"). On (' click ', ". B",function() {console.log (' 22222 ')})</ Script>

4. Foreign articles

<script>   $ (selector). Click (function() {console.log (' 1111 ')})</script >

If there are other options, please add

"Go" Issues with on click events failing in iOS

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.