ssssssss &"/> ssssssss &">

Home  >  Article  >  Web Front-end  >  zepto and jQuery on event delegation on iPhone

zepto and jQuery on event delegation on iPhone

一个新手
一个新手Original
2017-10-19 09:19:252074browse

The page made with zepto on the mobile terminal suddenly found that the click event bound to on was not triggered. The code is as follows:

<ul>  
  <li class="a">1111111aaaaaaasssss</li>  
  <li class="b">aaaaaaassssss</li>  
  <li class="c">ssssssss</li>  
</ul>  

<script>

  $(document).on(&#39;click&#39;,&#39;.c&#39;,function(argument) {  
    alert($(this).html())  
  })  
</script>

I changed this writing method to a non-event delegation method, and found that the click event was It can trigger


$(‘.a’).on(&#39;click&#39;,function(argument) {  
  alert($(this).html())  
});

Finally, try replacing $(document) with $('body') or $('ul'). The experimental result is:

$(document) No

$('body') No

$('ul') OK

The above is the detailed content of zepto and jQuery on event delegation on iPhone. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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