Home > Web Front-end > JS Tutorial > body text

Solution to invalid jQuery delegate event monitoring

黄舟
Release: 2017-06-26 10:09:29
Original
2178 people have browsed it

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>
Copy after login

to

<div data-href="ssss">
<p>ssssss</p>
<p>dddddd</p>
</div>
Copy after login

Because it involves some asynchronous loading content, the following code is used to implement the a tag Function

$(document).delegate(&#39;[data-href]&#39;, &#39;click&#39;, function () {            
if ($(this).data(&#39;href&#39;)) {
                location.href = $(this).data(&#39;href&#39;);
            }
        });
Copy after login

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.
Copy after login

Add CSS content

*[data-href]{cursor: pointer;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template