jQuery .on() and .delegate() doesn't work on iPad

后端 未结 7 766
北荒
北荒 2020-12-05 04:38

If you try this snippet on desktop, everything works.
Whenever you try it on iPad, it won\'t do anything.

相关标签:
7条回答
  • 2020-12-05 05:21

    I'm not sure why doesn't it work, it's probably a bug, but there's a nice workaround. Simply put onclick="" to the div you're delegating and it will work perfectly

    <div id="click" onclick="">Click here</div>
    <script>
    $("body").on("click", "#click", function() {
        alert("This works on iPad");
    });
    </script>
    

    fiddle

    0 讨论(0)
提交回复
热议问题