During the development of WeChat, I found a solution to the eventno response of jQuery delegate binding.
The kids on the front end changed the original code of the following structure
<a href="ssss"> <p>sssss</p> <p>dddddd</p> </a>
to
<div data-href="ssss"> <p>ssssss</p> <p>dddddd</p> </div>
Because it involves some asynchronous loading content, the following code is used to implement the a tag Function
$(document).delegate('[data-href]', 'click', function () { if ($(this).data('href')) { location.href = $(this).data('href'); } });
does not cause any problems on the PC browser, but when opened by the browser that comes with the iPhone 6, it directly failed.
Finally found the solution on stackoverflow, now recorded as follows:
On iOS there is no event bubbling without a cursor style. So in your CSS you need to add cursor: pointer; to the element.
Add CSS content
*[data-href]{cursor: pointer; }
The above is the detailed content of Solution to invalid jQuery delegate event monitoring. For more information, please follow other related articles on the PHP Chinese website!