append追加元素后click失效

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
    <ul class="type_list" id="type_list_1">
        <li class="active">全部</li>
    </ul>
    <span class="test">测试</span>
</body>
<script>
$(function() {
      $(#type_list_1 li).click(function(event) {
          console.log(123);
      });
      $(#type_list_1 li).on(click, function() {
          console.log(456);
      });
      $(document).on(click, #type_list_1 li, function() {
          console.log(789);
      });
      $(.test).click(function() {
          $(#type_list_1).append(<li>歌剧</li>);
      });
  });

</script>
</html>

 

append追加元素后click失效

上一篇:JS给select设置默认选中的值,添加selected属性


下一篇:js匿名函数和date对象,math对象