为了账号安全,请及时绑定邮箱和手机立即绑定

在当前li后添加新的li,不能执行已设定的方法?

在当前li后添加新的li,不能执行已设定的方法?

Zoe_z 2018-03-07 18:23:28
具体如图:具体代码如下:<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style ></style> </head> <body> <ul > <li>1:<input type="text" /><button type="button" class="add">增加</button><button type="button" class="del">删除</button></li> <li>2:<input type="text" /><button type="button" class="add">增加</button><button type="button" class="del">删除</button></li> </ul> <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js" ></script> <script> $(function(){ $('.add').click(function(){ console.log('dian'); $(this).parent('li').append('<li><input type="text" /><button type="button" class="add">增加</button><button type="button" class="del">删除</button></li>') }) $('.del').click(function(){ $(this).parent('li').remove(); }) }) </script> </body></html>
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 885 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信